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.