You need to be careful just using user.dir. The user dir can change depending on how the jar is run. If you run from the command line in the jar directory, for example, using java -jar myApp.jar,...
Type: Posts; User: Bent
You need to be careful just using user.dir. The user dir can change depending on how the jar is run. If you run from the command line in the jar directory, for example, using java -jar myApp.jar,...
I did some testing to check it out further. The results were interesting.
class.getResource returns a a different type of URL depending on whether you're running from a JAR or from a *.class file....
Well, to get at the problem, we need a get a fix on more details.
How are you running the JAR?
What is your classpath when you run it?
How are you setting the classpath?
What is your folder...
As a general rule: If it is in a JAR, it is not a File. You have to use the Class.getResourceAsStream methods to get at it.
If it is a file, (a REAL file, on your file system, NOT in the JAR) you...
You've got a lot more difficulty there. From what I understand, JAR files were not intended to be dynamic resource caches, but static ones. There are probably a number of issues but one was that JARs...
You'll probably want to use the getResourceAsStream method instead of getResource. If I understand it correctly, the file in the JAR doesn't represent a proper file for a File object, so trying to...
Usually when I have this problem reading files from JARs, it is a character case issue. When you're reading files from disk in windows, the file names are case insensitive. But when you're getting...