- Java Environment Building
1. After installing the Java version, set the environment variables. (My Computer-Properties-Advanced system Settings-Advanced tab-environment variables)
New Java_home "," PATH ", and" CLASSPATH "variables in system variables
Variable name: java_home
Variable Value: C:\Program files\java\jdk1.7.0_79
Variable name: PATH
Variable value:%java_home%\bin;%java_home%\jre\bin;
Variable name: CLASSPATH
Variable value:.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;
- Test environment variable Configuration
1. Win+r, enter CMD to enter command prompt
2. Enter "Java", "Java-version" and "Javac" respectively to view the results.
- Make the first Java program "HelloWorld"
public class HelloWorld {
public static void Main (String []args) {
System.out.println ("Hello World");
}
}
1. Win+r, enter CMD to enter command prompt
2. Enter "D:" (drive letter to open Java file)
3. Enter "CD D:\desktop" or "CD desktop" (Open the folder where the Java files are located)
4. Enter "Javac Helloworld.java" (Compile Java file)
5. Enter "Java HelloWorld" (View program results)
- CMD command Lookup
- "CD" opens a folder under the current directory or opens a folder under the current drive letter path, such as "CD desktop" and "CD D:\desktop"
- "Cd\" returns to the root directory
- "CD.." Return to the previous layer
- Dir View all directories under the disk
Java Environment Building and first program