I have a .jar file that I would like to be able to call without having to use a full file path to its location.
For example, if the .jar file is located at: /some/path/to/thearchive.jar
I'd like to be able to run it with:
java -jar thearchive.jar
instead of:
java -jar /some/path/to/thearchive.jar
when I'm elsewhere in the directory tree. In my specific case, I'm running a Mac with OS X 10.5.7 installed. Java version "1.5.0_16". I tried adding "/some/path/to" to PATH, JAVA_HOME and CLASSPATH, but that didn't work.
So, how do I setup to run a .jar from the command line without having to use its full path?
UPDATE: Another item to deal with would be arguments. For example:
java -jar /some/path/to/thearchive.jar arg1 arg2
This can have an effect on the way the question is dealt with as mentioned in the answers below.