After the JDK has been installed, some of the development tools under the Bin directory can only be executed under that path, so that when compiling and executing Java programs
Will be inconvenient, we need to be able to execute anywhere in the system, we can set the environment variable to achieve the goal
One, set in path
Steps:
Locate path in the Advanced system settings-environment variable-system variable, copy the JDK Bin directory path (including the bin) to the path and
number and other systems variables so that the JDK program can run anywhere in the system .
The disadvantage of such a setup is that when we want to switch the version of the JDK, we have to manipulate the path, which may have some system environment variables
Cause error Action
Second, through the parameter setting
To avoid these drawbacks, we can add another in the system environment variable, which is named Java_home, when you just need to put the bin
(excluding bin) is placed in the Java_home system variable, and then the parameter Java_home in path is formatted as follows
%java_home%\bin;
The middle of the two% number is the parameter, so you only need to change the java_home when you switch the JDK version
Three, CLASSPATH environment variable
The current classpath is designed to allow your Java program to run at any point in the system.
Steps:
Add Classpath to the system variable and copy your Java program path to Classpath
After this configuration, the files under the configured path can be run anywhere on the system.
Disadvantages:
1. When there are two class files of the same name one in the Classpath directory, the other in other places, if the Java program is executed
, the system automatically executes the class file in the Classpath directory, which can cause unnecessary trouble
2. The class file generated by your own Java program can be run anywhere in the system, so there is a great
Security risks
Use:
General Classpath can be configured like this
.; class file Directory
This allows you to execute the class file in the current directory, and then execute the classpath directory if the file in the current directory does not exist.
under the file
Summary: generally only need to configure path, you can call Java development tools anywhere
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Environment variables