Java – executable can be called Jar file instead of using its full path?
I have one Jar file, I want to be able to call it without using the full file path to its location
For example, if The jar file is located at: / some / path / to / thearchive jar
I want to run it:
java -jar thearchive.jar
Substitute:
java -jar /some/path/to/thearchive.jar
When I'm elsewhere in the directory tree In my specific case, I am running and installing OS X 10.5 7 Mac Java version "1.5.0_16" I try to add path, Java_ Home and classpath add "/ some / path / to", but it doesn't work
Then, how to set up to run from the command line Jar without having to use its full path?
Update: another item processed will be parameters For example:
java -jar /some/path/to/thearchive.jar arg1 arg2
This can have an impact on how the questions mentioned in the answers below are handled
Solution
You can add a variable to save the directory:
export JARDIR=/some/path/to java -jar $JARDIR/thearchive.jar
I'm not sure you can do it implicitly from environment variables