1. Install JDK. You can customize the installation directory and other information during the installation process. For example, select c: \ jdk1.6 as the installation directory;
2. After the installation is complete, right-click "my computer" and click "properties ";
3. Select the "advanced" tab and click "environment variables ";
4. in "system variables" (some companies do not allow users to modify system variables themselves. In this case, you can also set Java environment variables in "User variables ), set three attributes: java_home, path, and classpath (case-insensitive). if it already exists, click Edit"(If the value contains content, separate it with a semicolon ),Click "new" if it does not exist ";
5. java_home indicates the JDK installation path, which is the path c: \ jdk1.6 selected during installation. This path contains Lib, bin, JRE, and other folders (it is best to set this variable, because in the future, tomcat, eclipse, and so on all need to follow * this variable );
Path allows the system to recognize Java commands in any path. It is set:
% Java_home %/bin; % java_home %/JRE/bin
Classpath is the class or lib path of the Java load class. Only the class in classpath can be identified by the Java command and set:
.; % Java_home %/lib/dt. jar; % java_home %/lib/tools. Jar (Add. to indicate the current path)
% Java_home % refers to the previously specified java_home;
6. "Start"->; "run", type "cmd ";
7. type the following commands: "Java-version", "Java", and "javac". If a screen is displayed, the environment variable is successfully configured;
8. Now let's start the first JavaProgramRight.
9. Create a hello. Java file with no location restrictions. The location for creating my hello. Java file is c: \ helloworld. The source code is as follows:
Public class Hello {public static void main (string [] ARGs) {system. Out. println ("Hello Java, I am coming .");}}
10. "Start"->; "run ",
Type "cmd" to open the command line window,
Type "cd c: \ helloworld" to enter the c: \ helloworld directory,
Type "javac hello. Java" to compile the hello. Java file (after successful compilation, you will find that a hello. Class file is added to the C: \ helloworld directory ),
Type "Java hello" and execute hello. class file. After successful execution, you will find that the "Hello Java, I am coming. ") so far, we can determine that our Java environment variables have been set successfully.