ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL url = classLoader.getResource(\"com/x/y/z.cfg\"); File file = new File(url.getPath());
You can't create a File instance, because the only file you have is the JAR. That's why getResource() returns URL. You can get stream by using URL.openStream() method to read contents.