Java environment construction

Java environment construction

1. Java basic nouns

JDK (Java Development Kit): Java development kit, without JDK, there is no way to develop Java programs.

JRE (Java Runtime Environment): Java runtime environment, if we run a Java program, we have to install JRE.

JVM (Java Virtual Machine): Java virtual machine, which can run bytecode, it is the core of the entire Java technology, the cross-platform of the Java language is thanks to the JVM

 

The relationship between JDK, JRE and JVM:

 

 

 

 JDK software directory

  • bin: some running programs of JAVA, including compilers, interpreters, and other executable files;
  • db: JAVA DB database;
  • include: header files for native code;
  • jre: the operating environment of the JAVA program;
  • lib: the file used by the executable;
  • src: JDK class library, source code file.

 

Second, the Java development environment to build

To build a Java development environment, the first step is to install the JDK. You can download it on ORACLE official website, download path:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

 

Here I want to remind you that the installation files for different platforms and systems are different, and you should choose the appropriate version to install according to your computer's situation.

To check the computer version: Right-click on the computer and select Properties. The figure below shows that the operating system type is 64-bit, and the JDK version you choose to download must also be 64-bit.

 

 

 

 

Next, let's talk about the configuration of the Java environment under the windows system.

 

Step 1: Install JDK

 

In the window system, after downloading the JDK, click on the installer and follow the instructions to install it.

Verify that the JDK was installed successfully:

1) Click "Start"

2) Enter cmd in the search, press Enter to open the dos command line

3) Enter the command java -version and press Enter

 

If the Java version is displayed, the JDK installation was successful.

 

Step 2: Configure environment variables

1) Placement JAVA_HOME

Right-click "Computer", select "Properties", click "Advanced System Settings", and click "Environment Variables" in the "Advanced" tab of the pop-up window

Create a new system variable name: "JAVA_HOME", and fill in the jdk installation path for the variable value.

Click OK

 

2) Configure PATH

The system variable has a path variable by default, find it and click Edit

Add ;%JAVA_HOME%\bin, semicolon at the end of the variable value; mainly to separate the variable value from the previous path, in fact, it can also be placed in other locations in the Path, not necessarily at the end, the main thing is that you put To the location, use; to separate from the previous/behind path

 

3) Configure the CLASSPATH variable

New system variable name: "CLASSPATH", variable value .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;          //Remember there is a "."

 

Explain the environment variables in detail:

Set JAVA_HOME:

One is to facilitate reference. For example, if JDK is installed in the C:\jdk1.6.0 directory, set JAVA_HOME as the directory path, then when you want to use this path in the future, just enter %JAVA_HOME% to avoid each reference Both enter very long path strings;

The second is the principle of normalization. When the JDK path changes, you only need to change the variable value of JAVA_HOME. Otherwise, you need to change any document that references the JDK directory with an absolute path. Without JDK, the consequences can be imagined - system crash!

The third is that the third-party software will refer to the agreed JAVA_HOME variable, otherwise, you cannot use the software normally.

Click -> New JAVA_HOME in the column of system environment variables (JAVA_HOME points to the installation path of JDK)

path variable

The path variable enables us to run java applications anywhere in the system, such as javac, java, javah, etc., which is to find the directory where we installed the JDK,

Assuming that our JDK is installed in the C:\jdk1.6.0 directory, then the C:\jdk1.6.0\bin directory is our commonly used java application, we need to add the C:\jdk1.6.0\bin directory to this directory into the path environment variable.

classpath variable

The classpath environment variable is to let the java interpreter know where to find this class when we need to refer to a class written by others when developing a java program. Usually, sun provides us with some additional rich class packages, one is dt.jar and the other is tools.jar, both of which are located in the C:\jdk1.6.0\lib directory, so we usually put Add these two jar packages to our classpath environment variable set classpath=.;C:\jdk1.6.0\lib\tools.jar;C:\jdk1.6.0\lib\dt.jar.

 

Difference between JDK and JRE

JRE (Java Runtime Environment)  is the runtime environment of Java. For users of Java programs, not developers. If you only downloaded and installed the JRE, then your system can only run Java programs. JRE is a collection of environments necessary to run Java programs, including JVM standard implementations and Java core class libraries. It includes the Java virtual machine, Java platform core classes, and supporting files. It does not contain development tools (compiler, debugger, etc.).

JDK (Java Development Kit),  also known as J2SDK (Java2 Software Development Kit), is a Java development kit, which provides a Java development environment (provides tools such as compiler javac for compiling java files into class files) and runs Environment (provides JVM and Runtime auxiliary packages for parsing class files to make them run). If you download and install the JDK, you can not only develop Java programs, but also have a platform on which to run Java programs. JDK is the core of the entire Java, including the Java Runtime Environment (JRE), a bunch of Java tools tools.jar and Java Standard Class Library (rt.jar).

 

To quickly install the java environment, you can also refer to this document:

https://jingyan.baidu.com/article/4853e1e569357c1909f72620.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325236529&siteId=291194637
Recommended