What is the JAVA environment variable? Why do I need to set it? What is the operating principle of it? __ Small Knowledge

Source: Internet
Author: User

Java_home = your JDK installation location
CLASSPATH =.; %java_home%\lib
PATH =%java_home%\bin

The first java_home is mainly for the back 2.

The second classpath specifies the location of the default class library, such as the Lib directory on which the current directory and Java_home are set

The third path is to add the Java bin to the system path so that the command line or other program can invoke Java,javac, JAVAW, and so on.

In fact, if you use more than 1.5 version of the JDK, you can not set the CLASSPATH environment variables can normally run the program. Since version 1.5 of the JDK has a feature that automatically searches for class files under the current path, and when using Java's compile and run tools, the system can automatically load Dt.jar (a class library about the running environment. mainly swing packages) and Java classes in Tools.jar (the class library for some tools), so you no longer need to set the CLASSPATH environment variable.

However, the previous version does not have such a function, so we will see that the network will have such a configuration:

The previous point in this configuration indicates the current path, plus the Dt.jar and Tools.jar two files are added to the CLASSPATH environment variable.

From the top I don't know if you've found any problems, A 1.7 version is still using the 1.4 and the previous CLASSPATH environment variable configuration method, which seems to illustrate a problem, it industry rapid development, knowledge is constantly updated, the Internet actually has a lot of knowledge is lagging, so we must pay attention to such a problem, not too pragmatic.


So what is the role of the CLASSPATH environment variable?

If we have a lot of class files and put them under different paths, when we need to execute the files under the specified path, then the CLASSPATH environment variable shows its usefulness.


In some special cases we may use the temporary environment variable configuration. Let's say that when we borrow someone else's computer, we can't change other people's computer settings. I think the best way is a mobile U disk plus temporary environment variable configuration.

Temporary environment variable configuration You can use the DOS command to enter set on the cmd command line, and you will see all the environment variables on your computer

This means that adding a path to the existing settings has no effect on the configuration in the computer system.
The summary is:
Set: Use to view all environment variables for this machine; 
Set Variable name: View a specific environment variable; 
Set Variable name =: empty an environment variable; 
Set  variable name = specific value: Specifies the specified variable; 
Note: This configuration is only valid for the current DOS window, and the configuration disappears after the window is closed.


Reference ~

Http://www.cstor.cn/textdetail_8164.html

Http://blog.sina.com.cn/s/blog_7c6086150101fzna.html

Related Article

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.