Java installation manual
The entire process of JDK installation, and the method of verifying whether JDK is installed successfully.
1. JDK installation
Custom jdk installation location
install jre
Customize jre installation location
The installation is complete
2. JDK installed successfully
Use the command java -version to check whether the JDK is installed. After the installation is successful, the display is as follows:
Automatically generate the following folders
By default, the javac command is disabled.
3. Configure environment variables
3.1. JAVA_HOME
new buildJAVA_HOME
Create a new environment variable and click the OK button
The effect is as follows:
3.2. Java-related environment variables in Path
Create two new environment variables in Path
%JAVA_HOME%\bin
%JAVA_HOME%\jre\bin
Path already exists, click the Edit button.
Click the New button
Enter two environment variables respectively, and click the OK button.
4. The environment variable configuration is successful
To check whether the environment variable is configured successfully, use javac -version
the command
If the configuration is successful, javac related commands are already available
(note that the javac command can only be used normally after restarting cmd)
5. Run the Java program
If the Java program can be run, it means that the JDK is installed successfully.
To run a Java program, you first need to generate a class file and then run it.
5.1. Create Java files
Java file example:
HelloWorld.java code
public class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
5.2. Run javac command to generate class file.
cmd first enters the directory where the Java file is located. Use the following command:
javac 《Java文件全名》
Example run command:
Generate class file effect:
5.3. The effect of running the Java program
Run the Java program, the effect is as follows: