I. Why:
Java environment setting is the first step in learning Java.ArticleIt is very complicated, but there are actually three:
1. Specify the Java executable file path in the environment variable path;
2. Specify the library file (jar package) path required for the Java execution file in the environment variable classpath (the jar package name should be specified );
3. to shorten the length of the path written in the path and classpath, A java_home variable is usually added and referenced with % java_home % during use.
The first reason is thatCodeCompilation and execution are all based on the files/bin in the installation directory. After setting the file in the environment variable path, it can be called in any directory;
The second step is to run Java and the library file is required. Java will find the file specified in the environment variable classpath.
2. How to set it?
The key to other variables is classpath:
First, you must setProgramThe directory, that is.;Otherwise, the class not found error occurs;
Next, point to Rt. jar.
The complete classpath is:
C:/program files/Java/j2re1.4.2/lib/RT. Jar;.
Iii. Differences between setting environment variables in Linux and Windows:
1> set windows in "My Computer", "property", "advanced", and "environment variables"; Set Linux in the ETC/profile file, and add export after setting, after saving the file, run [root @ mypc] # source etc/profile
2> when multiple environment variables are set;And:Separated.