A lot of people have the problem that when they start from nautilus a JAR-application, that the CWD (Current Working Directory) is set to their home folder (and not the folder in which the JAR is in). This is a bug in Nautilus, not especially Linux.
If you know a trick to make it easier to start a Jar correct instead of opening a terminal and manually type there java -jar myJar.jar
, please post it below.
Thanks
A short code example of the problem:
File f = new File("ASimpleTextFile.txt");
System.out.println(f.getAbsolutePath());
In Windows, this prints: [The Path To The Jar]/ASimpleTextFile.txt
But in Linux, it prints: /home/[yourName]/ASimpleTextFile.txt
This is a very bad Idea because of we often use relative path's to configuration files. This way, they will not be found, because of the file is pointing to the homefolder.