You should understand the Java environment variables you configured

Source: Internet
Author: User

A lot of people have been blindly to the online replication paste other people's environment configuration, and then after the face of the confused asked why I was wrong?

I think there are people who have met, I was the first to touch the Java time also touched.

I still can see a lot of newbies in some Java groups are very upset about the environment configuration,

Hereby I write this article.

In fact, the configuration of environment variables is not as difficult as you think, as long as you are familiar with each of the variables you have to become very simple.

I think everyone (even if you're a novice) should have used cmd command-line commands.

Why would you use those orders directly? Why did you fail to configure the time or the error said no Javac this command? Have you ever thought about it?

Those commands that can be used directly are already configured in the system environment variable.

And Javac, Java, and so on are some of the commands that you need to configure.

1, Java_home environment variables (in fact, this can not be configured, just for the convenience of other configurations). It points to the JDK's installation directory, and software such as Eclipse/netbeans/tomcat finds and uses the installed JDK by searching for java_home variables.

2, CLASSPATH environment variable. The role is to specify the class search path, to use the already written classes, the premise is to be able to find them, the JVM is through the classpath to find the class. We need to set the Dt.jar and Tools.jar in the Lib subdirectory of the JDK installation directory to classpath and then the current directory "." It must also be added to the variable so that the JVM can compile your written Java files.

3. Path environment variable. The function is to specify the command search path, set the path variable, you can execute Javac/java and other tools in any directory.

Specific configuration Explained

On the Windows desktop, right-click "My Computer", "Properties", "Advanced", "Environment variables", in "system variables" we can see the values of the system's various environment variables. Double-click a variable name to modify the value of the variable, using ";" between the variable values. Separated. We can also "create new" variables that were not previously available. There are 3 environment variables associated with the JDK, "java_home", "path", "Classpath". The "path" variable already exists in my system, can add the new value directly (other variable values do not move, prevent other programs to run the exception), the other two variables need to be new.

"Java_home", set the JDK installation path, such as "e:\java\jdk1.5", hereinafter referred to as "%java_home%" (here is a bit reluctant to say, in fact, in the environment variable configuration,% your variable name% is equivalent to the value of the variable you configured) , so as mentioned above, in fact, this can not be configured, just for the convenience of other configurations).

"Path", set the path of each program in the JDK, "%java_home%\bin;%java_home%\jre\bin;" (can also be written as "e:\java\jdk1.5\bin;e:\java\jdk1.5\jre\bin;" )

"Classpath", set the path of each class in Java, ".; %java_home%\lib;%java_home%\lib\tools.jar "(can also be written".; E:\java\jdk1.5\lib;e:\java\jdk1.5\lib\tools.jar "). The previous "." No less, it represents the working path we have built for our Java class, and the other is the standard class library path that comes with the JDK.

If it is helpful to you, then I am very happy, if still do not understand and still struggling to configure the classmate can also use MyEclipse, it comes with the JDK and Tomcat server, you do not need to configure

Link: https://pan.baidu.com/s/1GHFW_Ns0QdVCKTzRXIx71w Password: PTWU myeclipse

But I really do not recommend the novice use MyEclipse, it occupies a large amount of memory, and many features are beginners to learn what is not needed

You should understand the Java environment variables you configured

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.