0

When double clicking an executable .jar file located in a folder on the Desktop the java program behaves differently than when launched with 'java -jar jarfile.jar' from the terminal.

When attempting any IO it seems it is always trying to read from the home folder. For example:

File file = new File("testfile.txt");

Java should be looking for this file "testfile.txt" in the same folder as the .jar file is launched. However, testing shows that this is actually being looked for in /home/user/testfile.txt

What is happening? Why does this work from the terminal and not when double clicking the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.