The below way is working
URL queryURL = getClass().getClassLoader().getResource("db.mongo.query/" + this.name + ".json"); String query = new String(Files.readAllBytes(Paths.get(queryURL.toURI())));