About the Java environment configuration (meaning and comparison of path and classpath)

Source: Internet
Author: User

Java Environment configuration (the installation directory for my JDK is: C:\Program files\java\jdk1.7.0_79):


First step: We need to load the path of all EXE files in the bin directory under the JDK directory into path so that we can compile and run Java files using the Java.exe and Javac.exe tools in any disk directory.


The first step of the previous work: to make it easier to load the bin directory, we define a variable named Java_home, write the path to the JDK C:\Program files\java\jdk1.7.0_79


A method for adding a new path to the system environment variable (PATH variable): 1. Add a new path directly at the beginning of the variable, and add a semicolon at the end. 2.%java%\bin;


Step two: Specify the directory for the class file to run for the virtual machine:


Added in the classpath variable .; The%java_home%\lib;%java_home%\lib\tools.jar must be added at the beginning.;( Point and semicolon), which is the search for a class file in the current directory for the virtual machine, followed by the Java API for the virtual machine specification.


Learn: path is compared to classpath.

Under DOS commands, you can set temporary variables for path and classpath, for example:

Set classpath=.; c:/;d:/; Under this DOS window, the Java Virtual Opportunity first looks for the class file in the current directory, because there is (dot and semicolon), if not. will be found in the C-drive directory, if not in the C-drive directory, will be under the D-Drive. If the variable is worth a semicolon at the end, and finally in the current directory to look for, if not, summary: Set CLASSPATH will first look for the class file in the Classpath directory, can not find to go back to the current directory to find. The path is searched in the current directory, and then the path is searched.

This article is purely personal learning experience, if there are errors, please correct me.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

About the Java environment configuration (meaning and comparison of path and classpath)

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.