Reputation: 193
I am trying to execute a program on command line having dependencies on external Jar files stored in jar folder.
It can be executed as below.
java -cp jar/somejar.jar:. MyProgram --abc xyz
Is there a possibility if I can do the same without mentioning the jar files, something like below?
java MyProgram --abc xyz
Upvotes: 0
Views: 37
Reputation: 178343
Set your CLASSPATH
environment variable to contain jar/somejar.jar:.
Assuming Unix/Linux, in a shell do
export CLASSPATH=/absolute/path/tothejar/jar/somejar.jar:.
Then the java
interpreter will rely on the environment variable if the command-line option isn't given.
Upvotes: 1