Configuration of win11 JDK17 installation and environment variables under windows (the configuration is simple and detailed, including how to use commands to run java files in IJ)

Table of contents

Table of contents

Preface

A preliminary understanding of the full text

1. Download JDK

1.1, official website download

1.2, Log in or register

1.3, download

1.4, If you don’t have an account, please read this

2. Start configuring environment variables (very simple copy and paste)

2.1, find the location

2.2, Create environment

3. Verify whether the environment is configured successfully

4. After installing JDK, run java code anywhere

4.1,Create text file

4.2, modify the file name 

 4.3, run the code

5. Run the java code created in IJ

6. Summary


Preface

  This chapter is a tutorial on the configuration of JDK17 in win11. It is also an exercise to test the environment installation before learning Java. This article adopts fool-proof installation and use, and for running it in txt text, the java code and usage command are directly run in IJ. Some experiences and insights into creating java code.

A preliminary understanding of the full text

1. Download JDK

1.1, official website download

Here we choose JDK17, the long-term stable version

https://www.oracle.com/java/technologies/downloads/#java8-windowsicon-default.png?t=N7T8https://www.oracle.com/java/technologies/downloads/#java8-windows

1.2, Log in or register

           It is recommended to register one for subsequent use. It doesn’t matter if you don’t have one. I will give you the network disk link below.

                                 Click to view the account. If you have an account, log in. If you don’t have one, create one.

1.3, download

Click on the exe file. After installation, we only need to keep clicking next and it will be installed by default.

1.4, If you don’t have an account, please read this

jdk-17.0.8.zip official version download丨latest version download丨green version download丨APP download-123 cloud disk 123 cloud disk provides you with the latest official version of jdk-17.0.8.zip official version green version download, jdk- 17.0.8.zip Android mobile version apk is free to download and install on your mobile phone. It supports one-click quick installation on the computer icon-default.png?t=N7T8https://www.123pan.com/s/9CetVv-khpw.html%E6%8F%90%E5%8F %96%E7%A0%81:2521

After downloading, we click to unzip the package and extract the file to      the path C:\Program Files\Java\

                        If there is no java folder, after you find the location, create the file and then unzip it.

After unzipping:

2. Start configuring environment variables (very simple copy and paste)

2.1, find the location

                                                    First, we right-click the win icon in the lower left corner

Then we select System and click Advanced System Settings

           Finally, we click on the environment variable and find it here. The next step is a very simple operation.

2.2, Create environment

                               Next, we only need to click New in the system variables

Then copy and paste these two lines correspondingly.

Java_Home
C:\Program Files\Java\jdk-17.0.8

The red line is the directory where jdk is installed, which is also the location of the file generated after decompressing the file downloaded from my cloud disk.

                               Next we continue to find the Path path in the system variable

                         After entering Path, we click New, then copy and paste the following

                                            %Java_Home%\jre\bin

It is recommended to place the created line in the upper position as shown in my picture to avoid conflicts.

How to operate: Just click on the one you just created, and then click Move Up in the picture.

At this point, the environment variables have been created. Be sure to click OK!!!, and click OK on all the files that were opened during the opening process.

3. Verify whether the environment is configured successfully

                                   First open the command console with win+r, then enter cmd, and then press Enter

                                                Next, we enter in the command box one after another

                                                               java -version

                                                              javac -version

                                       The version information as shown in the figure appears, indicating that the configuration is complete.

4. After installing JDK, run java code anywhere

4.1,Create text file

                                  Let’s just find a folder and create a txt text

public class hello {
    public hello() {
    }

    public static void main(String[] args) {
        for(int i = 0; i < 10; ++i) {
            System.out.println("Hello Word!");
        }

    }
}

4.2, modify the file name 

 Then copy and paste and save. Then note that the file name must be consistent with the class name and both are hello. The following is the modified txt file.

 4.3, run the code

Then, we enter cmd where the horizontal line is drawn at the top, and then the command box under this file will open, avoiding the trouble of entering the command box.

As shown in the picture, note that we need to javac the file name.java                     before running the java file.

                                     A hello.class appears in the picture, which is the generated file.

In Java, source code first needs to be compiled into bytecode before you can run it. The javac command is the command line tool of the Java compiler, used to compile Java source files (suffix .java). Its function is to compile Java source code (.java files) into bytecode files (.class files), and then you can use the Java Virtual Machine (JVM) to run these generated bytecode files. Therefore, before running Java code, compiling with javac command can ensure the correctness of the code and generate an executable bytecode file.

 Then we enter java hello and the java file will be run. Note that this time the .java suffix is ​​not required!!!

5. Run the java code created in IJ

            Here we only need to comment out the above package to run it using the command

This is what I discovered during my attempts. My own understanding is that after commenting out the package, it is equivalent to the file becoming a txt file just created. The same as the changed java file, it is not subject to IJ constraints, so You can run it with any command

6. Summary

This chapter is an attempt for me to install a newer version of the JDK environment . I have been using the old version before, which requires a lot of environment configuration, but the latest version is actually easier to configure than a novice.

Of course during the attempt, I encountered how to run the java file created by IJ using commands. After trying to search, I found many tutorials, which were difficult to understand and most importantly could not solve the problem at all. I was determined to solve it myself and after many attempts on my own Next, I found a solution, which is actually an improvement in my ability to solve problems.

A word a day

Don't be confused by your heart, don't be trapped by emotions, don't be afraid of the future, don't think about the past, it's so peaceful.

  If my study notes are useful to you, please like and save them. Thank you for your support. Of course, you are also welcome to give me suggestions or supplement the shortcomings in the notes. It will be of great help to my study. Thank you.  

Guess you like

Origin blog.csdn.net/weixin_72543266/article/details/132635736
Recommended