配置环境变量
1、安装JDK完后,右击"我的电脑",点击"属性",选择"高级系统设置";
2、择"高级"选项卡,点击"环境变量";
出现如图:
3、
在"系统变量"中设置3项属性,JAVA_HOME,PATH,CLASSPATH(大小写无所谓),若已存在则点击"编辑",不存在则点击"新建"。(个人建议在用户变量进行配置)
变量设置参数如下:
- 变量名:JAVA_HOME
- 变量值:C:Program FilesJavajdk1.8.0_162 // 要根据自己的实际路径配置
- 变量名:CLASSPATH
- 变量值:.;%JAVA_HOME%libdt.jar;%JAVA_HOME%lib ools.jar; //记得前面有个"."
- 变量名:Path
- 变量值:%JAVA_HOME%in;%JAVA_HOME%jrein;
注意:在 Windows10 中,因为系统的限制,path 变量只可以使用 JDK 的绝对路径。%JAVA_HOME% 会无法识别,导致配置失败。如下所示:
C:Program FilesJavajdk1.8.0_162in;C:Program FilesJavajre1.8.0_162in;
测试JDK是否安装成功
1、"开始"->"运行",键入"cmd";
2、键入命令: java -version、java、javac 几个命令,出现以下信息,说明环境变量配置成功;