Many people feel that configuring the environment variables for Java development is cumbersome, easy to forget, and often confused by it. If this is the case, then the reason is only one, you do not understand the need to configure environment variables for hair, do not configure environment variables can not be developed? The answer is: no!, then take everyone together to analyze why.
Define a concept first. Compiling a Java source requires using the Javac command, and running a Java program requires the use of a Java command. Take my machine For example, these two command tools exist in: D:\java\jdk\jdk1.7.0_06\bin path
A feature at the command prompt is the ability to access only the files below the current directory.
The premise that all the compile commands are executed correctly is that both the Javac.exe and Hello.java files must be under the current D:\java directory
As a result, we compile and run the first Java program as follows ...
This puts the compilation tool and the compiled file under a directory, which seems to solve the problem. But have you ever thought of a problem? If there are hundreds or thousands of items in a project that are placed under this JDK directory, what is the concept, too messy. So our proposal is to separate the project files and Java running Environment management, separate management means that Javac Hello.java the two files are not under a directory, then how to do? At this point we want to be able to access and use the Javac translation (Java) tool under any directory. Configure the path of the Javac,java two tools to the operating system, the following is a detailed configuration process:
Here is an example of an XP system: My Computer-Right-click Properties-Advanced-environment variables
Take Win7 For example: computer-Right-click Properties-Advanced system settings (Advanced)-Environment variables
Mode one: In the user variable group above click New, there is a picture to fill in the data;
Mode two: Select the system variable in the path after click Edit, at the end of the add to the right of the value of the variable (variable value before and after the addition of good).
There are almost no differences between the two ways, only the general path will have some software paths, if you are concerned about the error of other software to modify the path, add to the above user variables is actually good. Well, now that it's complete, we can access the Javac,java tool under any of the following paths. (Note that the Command prompt window that needs to be reopened is characters valid, and the configuration is not valid until you open the command prompts.) )
In addition to configuring path, Java_home,classpath can sometimes be configured.
Java_home: The value of the variable is configured to the root directory of the JDK, if Java_home is configured, then path can be written in relative%java_home%\bin; Some other software uses this variable, such as Tomcat,eclipse.
CLASSPATH: As the name implies is the path of the class file, configured under the specified path to find, generally do not configure, it will go to the current directory to start looking.
Concern
Getting Started with Java teach you to configure environment variables