It seems that under the Linux GUI (Gnome) a Java .jar cannot read external files that are in the same directory (relative path) as the .jar. This is because when running anything in gnome, the current directory defaults to $HOME so tries to find the files there. Under Windows and Mac, this does not happen and the .jar can read external files perfectly. I can also run java -jar ProgName.jar from the linux command line and it runs perfectly. How do I get around this problem with running in the Linux GUI? Here are some of my stipulations.
1. I do not want to put my external files in a jar 2. I want to access these files with a path relative to the jar 3. I want to make it easy for the user to download and run
Should I just not worry about a jar file, and just distribute the class files instead? You may have a look at http://adornthetruth.com/nikamo to get a better idea of the program I am working on. I currently distribute it as a zip file that has to be unzipped. In the zip file is the jar plus a folder containing the external files I want the jar to read in.
The java.class.path seems to work. I had tried the user.dir before and it just gives me the same as user.home. Now my question is, currently java.class.path only has path. If at some point the class path had more than one path, would the path to my main jar always be the first one?
Thanks again, I've been pulling my hair out about this one for a while now.