Java environment variables

Source: Internet
Author: User

When I first learned Java, I learned how to configure the environment variables. After many tossing times, I configured the environment variables. However, I did not care about the usage of each configuration item, once it can be used, it will be seldom taken care of. After a long time, we will understand the approximate functions of those variables.

1. java_home: Set it to the JDK installation directory, for example, D: \ Java \ jdk1.6. Some software dependent on Java obtains the JDK installation directory through this environment variable, such as Eclipse and tomcat.

2. Path: Add % java_home % \ bin at the end of the existing value, where; Is a separator used to separate each directory, % java_home % is the value of the above java_home environment variable, which can be directly replaced by the JDK installation directory. The classpath below is similar. The execution path (that is, the value of the PATH environment variable) is a list of directories that only search for local executable files in the operating system, it searches for the corresponding program in the execution path. Therefore, after adding the % java_home % \ bin directory to the path, you can execute javac or Java commands in shell.

3. classpath: set the value .; % java_home % \ Lib \ DT. jar; % java_home % \ Lib \ tools. jar; pay attention to the punctuation, the first vertex ". "indicates the current directory, while"; "indicates the separator.

This classpath loads the class directory for JVM, such as helloworld. there are other import classes in Java. During javac compilation, it will find the class you imported in classpath. If it cannot be found, a compilation error will occur.

In addition, when using Java, you can use the-classpath parameter to specify the directory of the class to be loaded. For example, run the command line: C:/usersjakey> JAVA-classpath D: \ Temp helloworld, in this way, you can execute the Java class in the d directory when the command line is in drive C.

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.