Configuration of Java Environment variables

Source: Internet
Author: User

 

Install JDK, such as directory in D:\Java\jdk1.7.0_71\bin

In order to facilitate the development of Java programs, you need to configure the environment variables, right-click My Computer---Properties----environment variable-----User variables in the [New (N)] Add the following environment variables

(Assuming that your JDK installation path is D:\Java\jdk1.7.0_71\bin)


Java_home
D:\Java\jdk1.7.0_71

PATH
D:\Java\jdk1.7.0_71\bin

CLASSPATH
.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar; (Note the preceding dot and semicolon must not be lost, and the middle, the semicolon in the back should not be lost)

Description: Classpath can add some third-party jar files, which is convenient to compile and run the program manually.

You can test it once you've built it up separately.

Description: If the computer is only using the variables above, it is recommended to set the user variable.

A simple test program can be written using tools such as Notepad, saved in D:\, with the following code:

publicclass Test {     public static voidmain(String[] args) {    System.out.println("Hello java!");    }}

Note: Keep in mind that the file name and class name are the same and the suffix name (. java)

Run cmd, enter the DOS interface, run java-version, and if the above environment is configured correctly, the current JDK version information should be displayed. (This command can be run in any directory)

Run Javac D:\Test.java, enter the same directory will compile the generated file Test.class,

Run D: Enter the D packing directory,

Run Java Text, enter output Hello java!

Configuration of Java Environment variables

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.