【转】运行java -version命令时出现错误及解决
转载地址:http://blog.sina.com.cn/s/blog_50f21fed01012sf2.html
按照上一篇的步骤配置JAVA_HOME、CLASSPATH和Path三个变量后,测试时执行 java -version出现如下错误:(执行javac命令和HelloJava.java都无错)
Registry key 'Software/JavaSoft/Java Runtime Environment/CurrentVersion'
has value '1.7', but '1.7.0-ea-b21' is required.
Error: could not find java.dll
Error: could not find Java 2 Runtime Environment
has value '1.7', but '1.7.0-ea-b21' is required.
Error: could not find java.dll
Error: could not find Java 2 Runtime Environment
网上查到解决方案如下:
(1)将path中java路径放在第一位;或者
(2)查找windows和system32目录,发现system32目录里有一个java.exe,估计是MS放进去的,Rename it。
但我尝试方案(1)仍然是上面的错误,方案(2)可行。
PS:可以查看下system32目录下几个java文件盒jre中的文件的差异。如java.exe javaw.exe javaws.exe等等进行