简体   繁体   English

JAVA_HOME路径问题

[英]JAVA_HOME path issue

I am using Windows 10. My JAVA_HOME path is set to the location of Java 1.7 but on executing 我正在使用Windows10。我的JAVA_HOME路径设置为Java 1.7的位置,但是在执行时

java -version 

in cmd, it gives version as Java 1.8. 在cmd中,它的版本为Java 1.8。 Can anyone tell me why I am getting this issue and how to fix it? 谁能告诉我为什么我遇到这个问题以及如何解决?

EDIT: In response to some of the fixes suggested, my system variable PATH too has the path to 1.7. 编辑:为响应建议的某些修复程序,我的系统变量PATH也具有指向1.7的路径。

Check your Windows PATH . 检查您的Windows PATH You probably installed Java 8 version and as it seems to be on the path before Java 7, this is the version that gets executed when calling java from the command line. 您可能安装了Java 8版本,并且似乎安装在Java 7之前的路径上,这是从命令行调用java时执行的版本。

JAVA_HOME is not used by Windows to pick up a Java Installation but is mainly used by tools/applications that require Java (such as IDEs or applications written in Java) to find the Java to use. Windows并不使用JAVA_HOME来进行Java安装,而是主要由需要Java的工具/应用程序使用(例如IDE或用Java编写的应用程序)来查找要使用的Java。

See https://stackoverflow.com/a/5102501/4323935 as well. 也请参阅https://stackoverflow.com/a/5102501/4323935

In the System Variable PATH, the Java 7's path must be in the front, not at the end. 在系统变量PATH中,Java 7的路径必须在最前面,而不是最后。 Are you able to execute java -version from the Java 7's directory and seeing the version displayed to be correct? 您是否能够从Java 7的目录执行java -version并看到显示的版本正确?

You can resolve this problem in either one of the below way 您可以通过以下任一方法解决此问题

  1. In the environment variables check your path whether it is starts with or path has C:\\ProgramData\\Oracle\\Java\\javapath , if yes then please remove it 在环境变量中,检查您的路径是否以C:\\ProgramData\\Oracle\\Java\\javapath开头,或者路径是否具有C:\\ProgramData\\Oracle\\Java\\javapath ,如果是,则将其删除
  2. Open Run then type system32 and press enter. 打开Run然后键入system32 ,然后按Enter。 search and find java.exe, javaw.exe and javaws.exe and delete it. 搜索并找到java.exe, javaw.exe and javaws.exe并将其删除。

After that set the JAVA_HOME and path(ignore if you already set it up). 之后,设置JAVA_HOME和path(忽略它是否已设置)。

Once you have done the above things then close cmd and reopen and try again 完成上述操作后,请关闭cmd并重新打开,然后重试

this is similar to Multiple java versions installed and java was started but returned exit code=13 这类似于已安装的多个Java版本并已启动Java,但返回了退出代码= 13

Try the following command. 请尝试以下命令。 It will show you the path for java being picked up in the command line. 它将向您显示在命令行中拾取Java的路径。

where java

Then, make sure it is not in your path: 然后,确保它不在您的路径中:

set PATH

First of all please check the PATH values typing 首先请检查PATH值的输入

echo %PATH%

Most probably you have java 1.7 path set in PATH, and it might be set before other java path 您很可能在PATH中设置了Java 1.7路径,并且可能在其他Java路径之前设置了它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM