Java Environment variables

Source: Internet
Author: User

    After the JDK has been installed, some of the development tools under the Bin directory can only be executed under that path, so that when compiling and executing Java programs
Will be inconvenient, we need to be able to execute anywhere in the system, we can set the environment variable to achieve the goal
One, set in path
    Steps:
    Locate path in the Advanced system settings-environment variable-system variable, copy the JDK Bin directory path (including the bin) to the path and
number and other systems variables so that the JDK program can run anywhere in the system .
    The disadvantage of such a setup is that when we want to switch the version of the JDK, we have to manipulate the path, which may have some system environment variables
Cause error Action
Second, through the parameter setting
    To avoid these drawbacks, we can add another in the system environment variable, which is named Java_home, when you just need to put the bin
(excluding bin) is placed in the Java_home system variable, and then the parameter Java_home in path is formatted as follows
                    %java_home%\bin;
    The middle of the two% number is the parameter, so you only need to change the java_home when you switch the JDK version
Three, CLASSPATH environment variable
    The current classpath is designed to allow your Java program to run at any point in the system.
    Steps:
        Add Classpath to the system variable and copy your Java program path to Classpath
    After this configuration, the files under the configured path can be run anywhere on the system.
    Disadvantages:
      1. When there are two class files of the same name one in the Classpath directory, the other in other places, if the Java program is executed
    , the system automatically executes the class file in the Classpath directory, which can cause unnecessary trouble
      2. The class file generated by your own Java program can be run anywhere in the system, so there is a great
    Security risks
    Use:
General Classpath can be configured like this
.; class file Directory
        This allows you to execute the class file in the current directory, and then execute the classpath directory if the file in the current directory does not exist.
    under the file    
Summary: generally only need to configure path, you can call Java development tools anywhere

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

Java Environment variables

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.