JDK环境配置: javac is not recognized as an internal or external command, operable program or batch file

时间:2022-05-05 09:27:11

相信大家在配置TestNG的时候,首先都会去确认JDK的安装是否正确,两个命令缺一不可。

打开‘cmd’ --> 

1. 输入'java -version', 返回java home当前路径。 

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

 JDK环境配置: javac is not recognized as an internal or external command, operable program or batch file

 

 

2. 输入‘Javac -version’, 返回Java编译器当前使用的JDK版本。

javac 1.8.0_11

 JDK环境配置: javac is not recognized as an internal or external command, operable program or batch file

 

 

这种时候,很多新手会碰上一个问题,关于Javac不能找到: javac is not recognized as an internal or external command, operable program or batch file

一般检查两个地方。

一是到环境变量中,先看系统环境变量叫做“JAVA_HOME”的是否配置为最新的JDK,不可以指向JRE哦!

二是到环境变量中,检查“PATH”是否配置正确。

步骤如下:

步骤一:打开计算机--属性--高级系统设置。

JDK环境配置: javac is not recognized as an internal or external command, operable program or batch file

步骤二:高级-环境变量

JDK环境配置: javac is not recognized as an internal or external command, operable program or batch file

步骤三: 配置“JAVA_HOME” = C:\Program Files\Java\jdk1.8.0_11(我用的1.8.0_11的版本,现在好像已经144了,无所谓,反正到你的C盘找到你的最新的JDK版本,加进来)

    PATH=%JAVA_HOME%\bin;%PATH%

步骤四:最后配置“CLASSPATH”

CLASSPATH=.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar

 

 

 JDK环境配置: javac is not recognized as an internal or external command, operable program or batch file

 

 

 步骤四:

新建“变量名”CLASSPATH在“变量值”文本框的起始位置添加“.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar”(注意最前面有一点)设置完成单击确定。

一切OK了。 请最后确认你的JAVA_HOME配置指向的是JDK,并不是JRE。再试试吧!

JDK环境配置: javac is not recognized as an internal or external command, operable program or batch file

 确认JAVA_HOME配置: echo %Java_Home%

JDK环境配置: javac is not recognized as an internal or external command, operable program or batch file