Configuration of Java base environment variables __java

Source: Internet
Author: User

configuration of Java Base environment variables

The configuration of Java environment variables mainly includes the following three important environment variables, as for the subsequent Web projects, you also need to configure Tomcat-related environment variables, here do not summarize.

A. Path

1. The significance of the existence of this environment variable is that as long as we add the executable path we often execute in the cmd command window to this path as variable value, we can execute the program in any directory in the cmd window, and the program will check if the current directory has a program to execute, if it does not exist, Then go to the directory where we have configured the path variable to find the program and execute it. Then we can add our Java installation path (such as D:\Java\bin) to the variable value of the path variable, so that we can execute the executable program under the Bin folder in any path, such as Javac.exe, Java.exe.


2. The characteristics of the PATH variable

A. It is an environment variable with the system, it is not recommended to delete or modify the default values inside.

B. Two different paths need to be separated by semicolons.

C. Path addressing: Find the current path first, if it is not found in the path set in the PATH variable.

D. However, there are multiple different paths, separated by semicolons.

two. Classpath variable

This variable is used to set point to the Java class file directory, such as the Java program we developed, the. class files are stored in the d:\javatest, we are generally directly in the console using CD instructions directly into the D:\ Javatest directory to execute the. class file, so how do we like path, after Setup, you can execute java. class files in any directory.

This is the time to create a classpath variable, the value of this variable set to our store. class file that the full directory, if there are more than one such directory, then multiple directories need to be separated by semicolons.

1. Mode one

Only set a directory, such as "D:\JavaTest", if so, when we want to do in any directory to execute a. class file, the system will only go to D:\JavaTest to find the execution of the. class file, if not the error.

2. Mode two

Set to "D:\JavaTest;", if set to do so, when we want to execute a. class file in any directory, the system will only go to D:\ Javatest look for the specified. class file, if not go to the current directory to find, if the current directory is not, then the error, in fact, "D:\JavaTest;" Set the Way and.;D: \ Javatest "Set the same way, because". " It represents the current path, but only "." You'll find the current directory before you put it in front.

3. Mode three

Set multiple Paths ".;D: \ Javatest; E:\JavaProject ", such settings, will first go to the current path to find, if not to D:\JavaTest under the search, if there is no E:\JavaProject to find, the last to or no, on the error.

three. Java_home variable

This variable is used primarily for subsequent modifications to the bin directory under the Java installation path in the redirected path path. In other words, if we replace the Java installation directory later, it means that we have to reset the path variable, it is more cumbersome, then how do we simplify the future maintenance.

Then we create a java_home variable, to store the Java installation directory, set the value, just set to the bin in the previous directory, such as we have "D:\Java\bin" this path is fixed to write to the path, then we will only "D:\JAVA "This part is set to Java_home, then the path can be simplified writing, can be written so%java_home%\bin can be, and in the future we just maintain the java_home variable on it, path does not change."




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.