Java版本指向错误的目录 [英] Java -version points to wrong directory
问题描述
我已经设置了环境变量。窗口7-32位
I have set my environment variables up. Window 7 - 32 bit
C:\Users\user>java -version
Error: could not open `E:\lib\i386\jvm.cfg'
C:\Users\user>echo %JRE_HOME%
C:\Program Files\Java\jre7\bin
C:\Users\user>echo %PATH%
C:\Program Files\PC Connectivity Solution\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\jdk1.6.0_22/bin;C:\Program Files\Java\jre7\bin/bin;C:\Ruby193\bin;C:\Ruby187\bin
C:\Users\user>java -version
Error: could not open `E:\lib\i386\jvm.cfg'
我检查了E:该位置没有任何东西。
我有JRE7和jdk1.6.0_22。
I checked on E: there is nothing on the location. I have JRE7 and jdk1.6.0_22.
您能给我解决方法吗?
我尝试使用此解决方案,
无法在Windows 7(64位)中正确设置Java的路径
,但是,单击控制面板上的JAVA时,会得到相同的结果错误信息。 [错误:无法打开ʻE:\lib\i386\jvm.cfg']
I tried to use this solution, Not able to properly set up the path of java in Windows 7 , 64 bit however, while clicking on JAVA present on control panel it is giving me same error message. [ Error: could not open `E:\lib\i386\jvm.cfg']
推荐答案
在安装时如果是JRE,安装程序会在Windows系统目录(例如C:/winnt/system32/java.exe)中写一个特殊的 java.exe
。该 java.exe
将在注册表中查找以获取当前JavaHome的位置。
When you install a JRE, the installer writes a special java.exe
in the Windows system directory (ex . C:/winnt/system32/java.exe). This java.exe
will look in the registry to get the location of the current JavaHome.
[HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion] (64 bits or 32 bits only)
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\CurrentVersion] (32 bits installed on OS 64 bits)
,然后获取JRE的路径用于标记为当前版本的版本。
and then get the path of the JRE for the version marked as current.
对于在Windows 64位安装上安装的32位JRE:
For a 32 bits JRE installed on a Windows 64 bits installation :
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\CurrentVersion] --> 1.8
然后
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\1.8\JavaHome] --> C:\Program Files (x86)\Java\jre1.8.0_31
因此请验证注册表中的值并清理您的PATH,因为您不需要它来通过仅键入 java.exe从命令提示符启动
。 java.exe
So verify the values in the registry and clean up you PATH because you don't need it to launch java.exe
from the command prompt by typing only java.exe
.
如果设置正确,则无需修改PATH即可覆盖默认JRE:
If your setup is correct, you will be able to override the default JRE without modifying your PATH :
> java -version:"1.6" MyClass (force the jre 1.6 installed to be used)
The JAVA_HOME
和 JRE_HOME
环境变量未被安装程序安装在程序文件中的JRE使用。 IDE,工具或应用程序服务器的约定。
The JAVA_HOME
and JRE_HOME
environment variable are not used by the JRE installed in the "Program Files" with the installer, they are used by convention by IDE, tools or application server.
这篇关于Java版本指向错误的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!