Executable files (built programs and shell scripts) normally go in /bin or /usr/bin but what about a jar file? It is a 'program' making me think it should go in bin, but on the other hand it requires a script to start it.
I have a very simply script to start the jar.
java -jar myapp.jarBut where should I put the jar file its self?
12 Answers
It depends on you, i would suggest not to use any place designated to store system wide binary files. Although you can put it in /usr/local/bin or any other designated place to store system wide binary files but as it is not a regular binary file you better put somewhere else. Your home directory may be a good place too.
Actually it does not matter where you are putting this as long as you are going to use full path to call it:
java -jar /path/to/myapp.jarWhereas if you want to put it somewhere in your PATH, you can add the path to the directory containing the file to the PATH (put it in ~/.bashrc):
export PATH=$PATH:/path/to/directoryMake sure the directory does not contain anything else (otherwise it would be a great place for running random malicious commands !!).
Now you can also create an alias of the command, for example:
alias myapp='java -jar /path/to/myapp.jar'put it in ~/.bash_aliases. Now you can run the application by just typing:
myapp 1 There is no definite location that you 'should' store your executable jars in. It is based solely on user preference. I find that keeping my executable jars on the desktop works best so i don't need to continuously travel through my file system to use them which can sometimes get lost if your memory isn't the best.
Also little sidenote, if you install Java 8 then you can use Oracles Java 8 Runtime so you can just double click on the jar.
Hope I helped answer your dilemma.