Java installation manual

Java installation manual

The entire process of JDK installation, and the method of verifying whether JDK is installed successfully.

1. JDK installation

insert image description here

Custom jdk installation location

insert image description here

install jre

insert image description here

Customize jre installation location
insert image description here

The installation is complete

insert image description here

2. JDK installed successfully

insert image description here
Use the command java -version to check whether the JDK is installed. After the installation is successful, the display is as follows:
insert image description here
Automatically generate the following folders
insert image description here

By default, the javac command is disabled.
insert image description here

3. Configure environment variables

3.1. JAVA_HOME

new buildJAVA_HOME
insert image description here

Create a new environment variable and click the OK button
insert image description here

The effect is as follows:
insert image description here

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.
insert image description here

Click the New button
insert image description here

Enter two environment variables respectively, and click the OK button.
insert image description here

4. The environment variable configuration is successful

To check whether the environment variable is configured successfully, use javac -versionthe 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)
insert image description here

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:
insert image description here

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:
insert image description here

Generate class file effect:
insert image description here

5.3. The effect of running the Java program

Run the Java program, the effect is as follows:
insert image description here

Guess you like

Origin blog.csdn.net/sgx1825192/article/details/129669962