Skip to content
Advertisement

How to set CLASSPATH in Linux to let java find jar file?

Under Linux I am trying to run a jar file as follows:

java -jar plantuml.jar -testdot

while having CLASSPATH set to any of the following (the file is located at /home/user/plantuml.jar):

export CLASSPATH=/home/user
export CLASSPATH=/home/user/
export CLASSPATH=/home/user/plantuml.jar

In either case, no matter how I define CLASSPATH, the java command gives an error Unable to access jarfile plantuml.jar. What am I doing wrong here?

Advertisement

Answer

You have to supply the complete path after the parameter -jar. So for your example you have to call

java -jar /home/user/plantuml.jar -testdot

The $CLASSPATH is only evaluated to find additional files (classes/resources) but not the jar file defined in the command line.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement