Jdk environment variable configuration
In Windows
Install and test the java Runtime Environment and implement HelloWorld.
1. Download j2sdk 1.6.0 _ 21 or later (http://java.sun. com, it is recommended to download its Java Documentation, which is the Java help Documentation ).
2. run the downloaded installer for formal installation (the following is assumed to be installed in c: \ jdk1.6.0 _ 21 \. We recommend that you do not have spaces in the installation path, but not in the \ Program Files directory !).
3. Set runtime environment parameters:
A. If it is Win95 or Win98, add the following three lines at the end of \ autoexec. bat:
Set JAVA_HOME = c: \ jdk1.6.0 _ 21
Set PATH = % JAVA_HOME % \ bin; % PATH %
Set CLASSPATH =.; % JAVA_HOME % \ lib
Note: --- use the doscommand notepad c: \ autoexec. bat to open notepad and add the preceding three statements.
B. For Win2000 and WinXP systems, right-click my computer and choose Properties> advanced> environment variables.
System variable-> New-> variable name: JAVA_HOME variable value: c: \ jdk1.6.0 _ 21
System variable-> New-> variable name: CLASSPATH variable value:.; % JAVA_HOME % \ lib
System variable-> edit-> variable name: Path is added at the beginning of the variable value: % JAVA_HOME % \ bin;
C. For Vista, Win7, and Win8 systems, right-click "computer" and choose Properties> advanced system settings on the left> advanced> environment variables.
System variable-> New-> variable name: JAVA_HOME variable value: c: \ jdk1.6.0 _ 21
System variable-> New-> variable name: CLASSPATH variable value:.; % JAVA_HOME % \ lib
System variable-> edit-> variable name: Path is added at the beginning of the variable value: % JAVA_HOME % \ bin;
(CLASSPATH has an English ending "." followed by a semicolon, indicating the meaning of the current path)
(Using the command line method to set environment variables will only take effect for the current window)
(When changing the Path variable, add a new Path instead of deleting the original value)
4. Use a text editor (for example, edit. com/notepad/UltraEdit/EditPlus) to write the following code and save it as a file: HelloWorld. java (the case must be correct! C: \ test \ HelloWorld. java)
/* HelloWorld. java */
Public class HelloWorld
{
Public static void main (String [] arg)
{
System. out. println ("Hello, World! ");
}
}
5. Open a DOS window and jump to the directory where HelloWorld. java is located.
C: \> cd \ test
6. Compile HelloWorld. java as HelloWorld. class.
C: \ test> javac HelloWorld. java
7. Run HelloWorld. class
C: \ test> java HelloWorld
Hello, World!
Step 5 ~ 7. batch processing can be simplified without switching the path. The method is as follows:
Create a notepad document in the folder where the java source file is located. Enter the following three lines of code:
Javac HelloWorld. java
Java HelloWorld
@ Pause
Save it as "Java Run batch processing. bat"
Double-click the batch processing file and the compilation and running results in the cmd window will appear. The results are as follows:
C: \ test> javac HelloWorld. java
C: \ test> java HelloWorld
Hello, World!
Press any key to continue ..