I created a JAR file with my Java program. This piece of code will open a few files inside a dir “Test”, which is in the same dir as the JAR file. Like this:
/
-- program.jar
-- /Test
-- *
If I run via terminal with: java -jar program.jar, it runs perfectly. But if I run graphically (right clicking on the jar file and Open with OpenJDK…), it doesn’t work properly. Just like if I ran from another directory.
Is it possible that when I run the JAR file graphically it’s running from another directory?
By the way, I’m running on Ubuntu.
Yes, you will get another current working directory… There would be two solutions:
1) Find the cwd by doing this hack:
2) If the files under
Testare static (does not change to often) the solution would be to package them inside the jar.