How to configure environment variables and Java environment variables
Many people think that configuring environment variables for Java Development is troublesome and easy to forget. It is often confused. If this happens, there is only one reason. You cannot solve the problem of configuring environment variables for Mao. Can't you develop it without configuring environment variables? The answer is: NO !, Let's take a look at the cause.
Determine a concept first. To compile a Java source program, you must use the javac command. To start a Java program, you must use the java command. Take my local machine as an example. These two command tools exist in the path D: \ java \ jdk \ jdk1.7.0 _ 06 \ bin.
In a command prompt, you can only access the files in the current directory.
All the commands must be predicate by execution. Both the javac.exe and Hello. java files must be under the current D: \ java directory.
So we compile and run the first Java program as follows ......
In this way, the compilation tool and the compiled file are put under a directory, and the problem will be solved. But have you ever thought of a problem? If a project has hundreds of thousands of price questions, it's too messy to put them under this jdk directory. Therefore, we recommend that you manage the project files and java runtime environments separately, which means that the javac Hello. java files are not in the same directory. What should we do? In this case, we hope to access and use the compile (javac) Translation and run (java) tool under any directory. Configure the path of the javac and java tools to the operating system. The detailed configuration process is as follows:
Take the Windows XP system as an example: My computer-right-click Properties-advanced-Environment Variables
Here, we use Win7 as an example: computer-right-click Properties-advanced system settings (advanced)-Environment Variables
Method 1: Click create in the above user variable group and fill in the data in the figure;
Method 2: select the Path in the system variable, click Edit, and add the variable value on the right side to the end (add points before and after the variable value ).
There is almost no difference between the two methods, but generally there are some software paths in the Path. If you are worried about changing the paths of other software, the user variables added above are actually good. Now the configuration is complete. We can access javac and java tools in any path. (Note: it is valid only when the command prompt is re-opened. The Command Prompt window opened before configuration is invalid .)
Besides configuring the Path, you may also configure JAVA_HOME and CLASSPATH.
JAVA_HOME: The variable value is configured to the jdk root directory. If JAVA_HOME is configured, the Path can be written as % JAVA_HOME % \ bin; other software will use this variable, such as Tomcat and Eclipse.
CLASSPATH: As the name implies, it refers to the path of the class file, which is configured under the specified path. Generally, no configuration is required. It will start searching under the current directory.
Followed: