Java Learning Notes (i.) I. JDK\JRE\JVM differences
| Name | Full
Name |
Chinese name |
| Jdk |
Java Development ToolKit |
Java Development Kit |
| Jre |
Java Runtime Environment |
Java Runtime Environment |
| Jvm |
Java Virtual Machine |
Java Virtual machine |
The relationship between the three layers from top to bottom consists of:
- JDK contains development tools for the runtime environment and Java
- The JRE includes the JVM and Java core class libraries and supporting files, which are Java's running platforms, and all Java programs must be run under the JRE.
- The role of the JVM virtual machine is to speak Java bytecode (i.e.
.class files, compiled from Java programs, and must use the Java interpreter to interpret execution), mapped to a local CPU instruction set or system call to the OS. The JVM uses different mapping rules based on different operating systems, allowing Java to cross the platform.
Note: Java is both a compiled and interpreted language, and the execution of Java programs must be interpreted and compiled in two steps:
Second, Java Development Environment Configuration 2.1 install JDK
Oracle Official website/java/java se/download
Download the corresponding version of the system and install it (Ps.) it is best to remember the path at the time of installation, when the environment is configured.
2.2 Environment variable Configuration
You need to configure three environment variables:
Java_home Configuring the JDK installation path
PATH to configure the location of the JDK command file
CLASSPATH Configuring the location of a class library file
1. Computer Right-click Properties---> Advanced system settings---> Environment variables
2. Environment variable----> NEW
1. New variable name "Java_home", Variable Value "C:\Program files\java\jdk1.8.0_171" (i.e. JDK installation path)
2. Edit the variable name "Path", add ";%java_home%\bin;%java_home%\jre\bin" at the back of the value of the original variable
3. New variable name "CLASSPATH", Variable Value ".; %java_home%\lib;%java_home%\lib\dt.jar;%java_home%\lib\tools.jar "C:\Program files\java\jdk1.8.0_171
2.3 Confirm that the environment is configured correctly
1. Windows console input java -version can see the current JAVA version
PS. You can try other Java commands, such asjava
2. Verify the first Java program under the console
-
Notepad new TXT file, fill in the following code
public class Test {public static void main(String[] args) { System.out.println("Hello World!");}}
- Rename the file to
test.java
-
In the C-drive directory (or other directory, before entering the command, you need to change the CD command to the directory where the current. java file is located), enter the following command inside the console:
javac Test.java
java Test
Note: Case sensitive
At this point, the Java development environment is configured successfully.
Java Learning Notes (i)