Running .jar File on Linux

directory, jar, java, linux

Solution

First, try running it on the command-line, with

`java -jar <file.jar>`

The `user.dir` property is cross-platform (see here) so it should not be the problem. However, are you using correct file separators? Remember it's '/' on UNIX and '\' on Windows.

Problem

I have a .jar file that reads two files from within its current folder and produces as output a .txt file and a separate folder with multiple other .txt files. This works perfectly in Windows using this code to create the directory: ``` static String dir = System.getProperty("user.dir"); ``` I used the instructions here: https://askubuntu.com/questions/192914/how-run-a-jar-file-with-a-double-click to set up my .jar file to run on a simple double-click, but as of right now, it does nothing when double-clicked. My guess is that the above line of code does not translate well to Linux. Anybody know how to resolve this?

Original source