JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again

现象:

进行Java程序的编译与运行。

在操作过程中报错,具体为javac编译成功,而java运行报错;如下图:

JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第1张图片

 错误为:Error: A JNI error has occurred,please check your installation and try again (错误:JNI错误发生,请检查您的安装,然后重试。)

查因:

1.使用命令:分别查看javac、java的版本号

javac -version
java -version

JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第2张图片

2.使用命令:看java命令的具体路径

where java

解决:

1.首先进入高级系统设置界面

JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第3张图片

 JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第4张图片

2.单击环境变量选项卡

 JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第5张图片

 3.双击击系统变量中的Path变量

JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第6张图片

4.可以看到存在两个版本的java,而我目前使用的是%JAVA_HOME%\bin路径,所以将此选项上移到另一个java上方即可   

或者直接删掉多余的那一个。

JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第7张图片 

JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第8张图片

JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第9张图片

验证:

JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第10张图片

运行成功~

 注意:

1.配置完成后不要忘记点确定!!!

 JAVA--命令行窗口-java运行报错:Error: A JNI error has occurred,please check your installation and try again_第11张图片

2.验证的时候要重新打开命令行窗口!!!

你可能感兴趣的:(JAVA,java)