java JAVA_HOME 设置但不生效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30023545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JAVA_HOME set but not taking effect
提问by Jabir
As depicted in above image java home is set and is being echoed but when i check for version it gives me latest version. Already restarted the command prompt after setting env variable. OS is Windows 7
如上图所示,java home 已设置并正在回显,但是当我检查版本时,它给了我最新版本。设置 env 变量后已经重新启动了命令提示符。操作系统是 Windows 7
Update:
更新:
Following is the Path.
以下是路径。
..ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;;%JAVA_HOME%/bin;
..ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;;%JAVA_HOME%/bin;
回答by nazar_art
I had the same trouble and I solved it with following steps:
我遇到了同样的问题,我通过以下步骤解决了它:
You need correct environment variables
.
你需要正确的environment variables
.
To be exactly correct only Path
variable.
要完全正确,只有Path
变量。
You need to find where you add JAVA_HOME
to path.
您需要找到添加JAVA_HOME
到路径的位置。
Put it at first placeat Path
variable:
把它在首位的Path
变量:
%JAVA_HOME%\bin;...
%JAVA_HOME%\bin;...
instead ...
all other values of Path
.
取而代之的是 的...
所有其他值Path
。
I assume that JAVA_HOME
is defined as a variable and had correct value.
我假设它JAVA_HOME
被定义为一个变量并且具有正确的值。
After this reopen console and check:
在此重新打开控制台并检查后:
java -version
java - 版本
回答by Jigar Joshi
JAVA_HOME
is environment variable that various application reads in their launcher script
JAVA_HOME
是各种应用程序在其启动程序脚本中读取的环境变量
when you invoke java
it looks up for all paths specified in your env variable named PATH
and wherever the first match is it gets picked up
当您调用java
它时,它会查找您命名的 env 变量中指定的所有路径,PATH
以及第一个匹配项在哪里被拾取
so if you like command prompt to refer to jdk 6's Java append the path to PATH
因此,如果您希望命令提示符引用 jdk 6 的 Java,请将路径附加到 PATH
回答by Aakash
Check your PATH
environment variable also. Your system is referring to latest Java installation through PATH variable.
PATH
还要检查您的环境变量。您的系统通过 PATH 变量引用最新的 Java 安装。
回答by Sach141
I think in your path
variable you have hardcoded the path to bin
folder. it should always be %JAVA_HOME%/bin
.
我认为在你的path
变量中你已经硬编码了bin
文件夹的路径。它应该总是%JAVA_HOME%/bin
。
So that it can pick path from JAVA_HOME
variable and you don't need to change both the variables every time.
这样它就可以从JAVA_HOME
变量中选择路径,并且您不需要每次都更改这两个变量。
回答by Prasad Kharkar
You need to add the path to jJAVA_HOME%/bin
directory in the path
variable too. java
command is located in %JAVA_HOME%/bin
您还需要jJAVA_HOME%/bin
在path
变量中添加目录的路径。java
命令位于%JAVA_HOME%/bin