Article thoroughly get to know the Java environment variables

You get a text Java environment variables

Remember new to Java, the first thing is with the environment variable, as a beginner, only know how to fit the environment variable, plus a variety of IDE so that we can facilitate the development, while ignoring the essence of things, only know not why, with the continuous in-depth, and finally understand the meaning of the Java environment variables are represented.

First we look at the Java environment variables, for example in my own

  • JAVA_HOME:C:\Program Files\Java\jdk1.8.0_144
  • PATH:%JAVA_HOME%\bin
  • The CLASSPATH :. (A lower English .and some version is .;also followed this .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;)

In the Linux environment variables
Snipaste_2019-07-27_21-32-09.jpg

Let's take to solve the first problem, why do we have to configure the environment variables?

Speaking configuration environment variable, if we can not not configured to run java program yet? The answer is as long as the display jdk installation (or jre) We can run our .class files, but this time wanted to run successfully at run time, how should the following manner:
Snipaste_2019-07-27_21-48-37.jpg

And with a good environment variable to compile and run the process as follows:
Snipaste_2019-07-27_22-03-54.jpg

We can see the environment variable role is to help us eliminating the java、javacabsolute path in front of the command, but its function can be used directly.

We take a look at the built-in Windows environment variables:
Snipaste_2019-07-27_22-22-05.jpg

We are concerned about them%SystemRoot%\system32

Snipaste_2019-07-27_22-36-23.jpg

The %SystemRoot%\system32folder is the decentralization of the Windows system files, such as cmd.exe、calc.exe、dxdiag.exe、msconfig.exe, etc., enter the file name can be run directly in the cmd between these files, but if the environment variable %SystemRoot%\system32after deleted, it can not run these programs.

Now I would like to environment variables we should have a deep understanding of: with a good environment variable, when we run the program, the system will automatically find programs that we want to perform in the environment variable corresponding directory, thus eliminating the need for command a long list of absolute path before.

Finally, we explore in detail about the specific role of java environment variables:

  • JAVA_HOME:C:\Program Files\Java\jdk1.8.0_144

    JAVA_HOME is to specify the installation directory of jdk

  • PATH:%JAVA_HOME%\bin

    PATH is the directory where the command specified JAVA

  • The CLASSPATH :. (A lower English .and some version is .;also followed this .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;)

    CLASSPATH position specified bytecode to be executed (.class) file

    By a simple example to understand CLASSPATH
    Snipaste_2019-07-27_22-53-29.jpg
    while Hello.class not perform file java Hello.classdirectory command, but .class file specified by the parameter can then run any position -classpath Hello.class file.

Guess you like

Origin www.cnblogs.com/minghaiJ/p/11257762.html