Java environment variablesProgramImpact
Java_home =/opt/Java/jdk1.6.0 _ 13
Classpath =.: $ java_home/lib: $ java_home/JRE/lib
Path =.: $ path: $ java_home/bin: $ java_home/JRE/bin
The environment variable classpath is closely related to Java program development,
When you use javac to compile a Java program, the compiler searches for related classes in the path set by classpath,
For example, if the. Class is configured in classpath, that is, the current directory, the compiler will find the corresponding class from the current directory,
For example:
[Root @ localhost perfanalyzer] # ls test/javatest/
Datacollector. Class javatest. jar test. Class
Datacollector. Java manifest. MF test. Java
If the environment has changed and classpath is not configured, the following error occurs during compilation because datacollector will not be searched from the current directory after compilation,
If it is configured, the compilation is normal:
Test Java: Execute./test/javatest/test. Java
Test. Java: 23: The symbol cannot be found.
Symbol: Class datacollector
Location: class test
Datacollector collector = new datacollector ();
In addition, note that the environment variable classpath should be configured to the underlying path of the relevant package,
For example:
* **/Lib has many *. jar package. If you configure classpath at the ***/lib directory level, the compiler will not automatically search for classes in the jar package under the lib directory, it will only find * in the lib directory *. java. In this case, the absolute paths of all jar packages must be appended to classpath one by one, so that the compiler will automatically parse the jar package and find the relevant classes in it.
However, for the JDK library file jar, in $ java_home/lib, mainly tools. jar and DT. Jar
[Root @ localhost lib] # ls *. Jar
DT. Jar htmlconverter. Jar jconsole. Jar sa-jdi.jar tools. Jar
It seems that you do not need to point to the absolute path of the jar