ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL url = classLoader.getResource("com/x/y/z.cfg");
File file = new File(url.getPath());
This works when running jar file from Eclipse but not works when running in a jar file.
java.io.FileNotFoundException: file:\C:\Users\nova\Desktop\Matcher.jar!\c om\x\y\z.cfg
This is not a duplicate. I've checked all other questions, no useful information.
When file is bundled inside the jar then it become byte stream instead of a normal File object.
Try
More Tutorial...
Read similar post here and here
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.