ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL url = classLoader.getResource(\"com/x/y/z.cfg\"); File file = new File(url.getPath());
When file is bundled inside the jar then it become byte stream instead of a normal File object.
Try
InputStream stram=getClass().getClassLoader().getResourceAsStream(relativePath);
More Tutorial...
Read similar post here and here