Because I have a lot of hair, I am often regarded as a programmer who does not work hard; therefore, I come to learn Java, and I hope that I will become stronger even if I become bald!
The first is the installation of java. According to the suggestion of our company java, jdk8 and jdk17 are installed! Because among the many versions, only java8, java11, and java17 are long-term supported versions, which is better than stability! Steady as an old dog!
Table of contents
Record the relationship between jdk, jre, and jvm
Record the relationship between jdk, jre, and jvm
JVM : The English name (Java Virtual Machine), is the Java virtual machine we are familiar with. It only recognizes files of the type xxx.class, and it can recognize the bytecode instructions in the class file and call the upward API of the operating system to complete the action. Therefore, jvm is the core of Java's ability to cross platforms, which will be explained in detail below.
JRE : English name (Java Runtime Environment), we call it: Java Runtime Environment. It mainly includes two parts, the standard implementation of jvm and some basic class libraries of Java. Compared with the jvm, it has a part of the Java class library.
JDK : English name (Java Development Kit), Java Development Kit. jdk is the core of the entire Java development, it integrates jre and some useful gadgets. For example: javac.exe, java.exe, jar.exe, etc.
The relationship between these three is: nested relationship; JDK>JRE>JVM .
Download and install jdk8
First of all, we have to download java8 , just download it according to your computer configuration
But there will be a problem, you need to log in to the oracle account, after filling in the registration information carefully, the registration is still not successful, because there are too many things to fill in, I recommend a website! oracle account , find an account password immediately after entering, and log in to oracle to download.
As for the installation, there is nothing to say, it is a fool's installation, the only thing worth noting is the installation path, I changed it to the D drive.
Then there will be a pop-up box asking if you want to install jre. I modified the installation path. In fact, it doesn’t matter if you install it or not, because jdk already includes jre
installation location
Configure environment variables!
First add a system variable value, and then add it to the path
open a cmd
success!
Download and install jdk17
Download address java17
The installation of java17 is more foolish, just modify the installation location and go all the way down
As for environment variables, java17 has already configured them for us! But I still want to move~.~
same as java8
As for java17 itself setting environment variables for us, just delete them, that is this
reopen a cmd
As for the java environment switching, it is also very simple, you can switch in the idea, or whoever is on top is the boss!
Here java17 is above, that is the environment of java17!
Write a Hello World!
When learning any language, the teacher will teach the first lesson, and everyone outputs a hello world!
Create a new HelloWorld.java file
class HelloWorld {
public static void main(String[] args) {
System.out.println("hello world");
}
}
In the current directory, execute javac HelloWorld.java
You will find that a file called HelloWorld.class is generated, and then run java HelloWorld . Do not add .class
You can see that our hello world has been printed out!
Stop here, let me take it easy. . .