adding classpath in linux

后端 未结 5 1839
梦毁少年i
梦毁少年i 2020-12-03 02:11
export CLASSPATH=.;../somejar.jar;../mysql-connector-java-5.1.6-bin.jar
java -Xmx500m folder.subfolder../dit1/some.xml
cd ..

is the above statement

5条回答
  •  感动是毒
    2020-12-03 02:37

    Important difference between setting Classpath in Windows and Linux is path separator which is ";" (semi-colon) in Windows and ":" (colon) in Linux. Also %PATH% is used to represent value of existing path variable in Windows while ${PATH} is used for same purpose in Linux (in the bash shell). Here is the way to setup classpath in Linux:

    export CLASSPATH=${CLASSPATH}:/new/path
    

    but as such Classpath is very tricky and you may wonder why your program is not working even after setting correct Classpath. Things to note:

    1. -cp options overrides CLASSPATH environment variable.
    2. Classpath defined in Manifest file overrides both -cp and CLASSPATH envorinment variable.

    Reference: How Classpath works in Java.

提交回复
热议问题