Java environment variable configuration, java environment variable
1. Java installation
1. Download the appropriate version and install jdk and jre in the same folder in the same path. For example, both are installed in E: \ Java;
Note:JDK: Java Development Kit;JRE: Java Runtime Environment
To run a java program, you only need to install JRE.If you need to write a java program, you need to install JDK.
2. environment variable configuration 1. Three Ways to edit environment variables
1) Computer → properties → advanced system settings → advanced → environment variables;
2) Search for env in the upper-right corner of the control panel, and then click Edit Account environment variable
3) Click Start in the lower-right corner of the desktop.→ User Account→ Change my environment variables
2. environment variable configuration (JAVA_HOME, Path, CLASSPATH)
1)JAVA_HOME:The variable value is the personal jdk installation directory (for example:E: \ java \ jdk1.8.0 _ 31)
2)Path: Find the path in the system variable. If no path is created, enter % JAVA_HOME % \ bin; % JAVA_HOME % \ jre \ bin at the end of the variable value;
Note: If the original path has a value, a semicolon is required at the end of the value, and then a value is added;
3)CLASSPATH:.; % JAVA_HOME % \ lib \ tools. jar
Note: note the beginning
3. Setting Java environment variables will take effect for all users on this machine after setting user variables and system variables;
The user variable setting is only valid for the current user;
Generally, system variables are set without special requirements.
3. Check whether the installation is successful:
1. Enter java-version in the cmd window to view the java version information;
2. Compile a simple class test:
For example, a simple test class of Bird. java is put under E: \ aa:
public class Bird{ public static void main (String[] args){ System.out.print(1111); }}
1) cd \ returns to the root directory;
2) E: Enter the E-disk directory;
3) enter the cd aa folder;
4) javac Bird. java compiles java files;
5) Java Bird runs the java class file.