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.jar
But where should I put the jar file its self?
Best Answer
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:
Whereas if you want to put it somewhere in your
PATH
, you can add the path to the directory containing the file to thePATH
(put it in~/.bashrc
):Make 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:
put it in
~/.bash_aliases
. Now you can run the application by just typing: