One, foreword

Setting environment variables is the first step to do in Java for many years, but why to configure environment variables, and what is used, today nezha will take you to find out.

2. Baidu Encyclopedia

Something has nothing to find Baidu, Baidu explain the noun this piece is really good.

1. Introduction to environment variables

Environment variables are generally used to specify operating system operating environment parameters, such as temporary folder location and system folder location.

An environment variable is an object with a specific name in the operating system that contains information that will be used by one or more applications. For example, the path environment variable in Windows and DOS operating systems, when the system is asked to run a program without telling it the full path of the program, the system should not only look for the program in the current directory, but also look for the path specified in the path. Users can set environment variables to better run the process.

2. The main role of environmental variables

(1) Set parameters

The path environment variable is used to tell the system what directories to look for in addition to the current directory when it is asked to run a program without telling it the full path of the program. The path variable we normally configure is the full path to the directory.

In a nutshell, when some parameters are needed to run a command, if they cannot be found in the current directory, they are automatically searched in environment variables.

(2) Software sharing

Many of my friends have dual systems installed on their computers, such as Windows XP on drive C and Windows 7 on drive D. However, some software is usually only installed in Windows XP system, Windows 7 system is not normal use, more troublesome but effective method is to install again. When we understand the use of environment variables, we can solve the problem of software sharing in dual systems.

(3) System operation

Why does software installed on Windows XP not work on Windows 7 (except for green software)? The reason is that when installing software, you often need to copy certain files to the system directory, and when using another system, they cannot run because of the lack of these files. Therefore, we can solve this problem by setting environment variables.

Java environment variables

1, Java Development Kit (Java) composition

The JDK is a Java language software development kit, mainly used for Java applications on mobile devices and embedded devices. JDK is the core of the whole Java development, it contains the Java runtime environment (JVM+Java system class library) and Java tools.

The Java Runtime Environment (JRE) consists of a Java Virtual Machine (JVM) and some standard libraries.

So here we have the relationship between JDK, JRE, and JVM.

Let’s take a look at the JDK directory after installation.

The bin directory is the Java executable file, including the Java, Javac, Javadoc development instructions that we often use, and the instruction programs used in the compilation and execution of our program are all in this directory.

2. Run javac

If CMD is not found in the current path, the CMD will be found in the path variable. If CMD is not found, an error will be reported.

Configured Java environment variables:

If environment variables are not configured, can the javac command run in the bin directory? Can it run on any other path?

Try, simply, changing the path to javA_HOME

Can the javac command run in the bin directory?

Can it run on any other path?

4. So why can’t JDK paths be configured directly in path instead of a separate JAVA_HOME?

This is part of the Java development process, because when Java was first used, it was necessary to set up and use a Tomcat server, and it is still required now, but SpringBoot is integrated with Tomcat and does not require a separate boot.

JAVA_HOME = JAVA_HOME = JAVA_HOME = JAVA_HOME = JAVA_HOME = JAVA_HOME = JAVA_HOME = JAVA_HOME = JAVA_HOME = JAVA_HOME = JAVA_HOME

Everyone [likes, favorites, attention, comments], interested can find me to give you