[Java] how to configure Java environment variables in Windows

Source: Internet
Author: User

Everyone who learns Java must be first exposed to the configuration of environment variables. Although the basics are the only way to go.
To sum up, there are several steps:


1. Download and install JDK.

It is often hard to figure out the differences between JDK and JRE.

JDK is short for javasdk, including the Java Runtime Environment, Java tools, and Java base class libraries.

To run only Java programs, make sure that the corresponding JRE (Java Runtime
Enviroment ).

Without JDK, you cannot compile Java programs;

Java programs cannot be run without JRE.

This is the difference.


2. Configure environment variables: My computer -- properties -- Advanced -- Environment Variables


2.1 create a system variable java_home

It should be noted that java_home is the installation path of your JDK. This is true if not all JDK users have installed java_home,

Go to the JDK installation directory and copy and paste the directory. My JDK is installed in the default path, so the value is as follows:


Variable name: java_home
Variable value: C: \ Program Files \ Java \ jdk1.7.0


2.2 create a system variable classpath

Classpath is set on the basis of java_home, so you don't need to care about the path, just copy the following:


Variable name: classpath
Variable value:.; % java_home % \ Lib \ DT. jar; % java_home % \ Lib \ tools. jar;

2.3 modify the system variable path

Select the environment variable named "path" in "system variables" and double-click the variable to add the absolute path of the bin directory in the JDK installation path to the value of the PATH variable, separate the half-width semicolon with an existing path.

Note that you must use semicolons to separate the added Java variables from the original variables.


Variable name: Path
Variable value: % java_home % \ bin; % java_home % \ JRE \ bin; + original content



Next, win + R, Enter cmd and press enter to open the command prompt line window, and enter javac. If the following content is displayed, the Java environment is successfully configured.


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.