JAVA_HOME设置但未生效

时间:2021-05-31 23:02:40

JAVA_HOME设置但未生效

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;

5 个解决方案

#1


I had the same trouble and I solved it with following steps:

我遇到了同样的麻烦,我按照以下步骤解决了这个问题:

You need correct 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 place at Path variable:

把它放在Path变量的第一个位置:

%JAVA_HOME%\bin;...

instead ... another values added to your Path.

而是...添加到您的路径的另一个值。

I assuming that JAVA_HOME is defined as a variable.

我假设JAVA_HOME被定义为变量。

After this reopen console and check:

重新打开控制台并检查后:

java -version

#2


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时,它会查找你名为PATH的env变量中指定的所有路径,以及第一个匹配的地方,它会被拾取

so if you like command prompt to refer to jdk 6's Java append the path to PATH

所以如果你喜欢命令提示符来引用jdk 6的Java追加到PATH的路径

#3


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目录的路径。 java命令位于%JAVA_HOME%/ bin中

#4


Check your PATH environment variable also. Your system is referring to latest Java installation through PATH variable.

检查您的PATH环境变量。您的系统是指通过PATH变量进行的最新Java安装。

#5


I think in your path variable you have hardcoded the path to bin folder. it should always be %JAVA_HOME%/bin.

我认为在你的路径变量中你已经硬编码了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变量中选择路径,并且您不需要每次都更改这两个变量。

#1


I had the same trouble and I solved it with following steps:

我遇到了同样的麻烦,我按照以下步骤解决了这个问题:

You need correct 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 place at Path variable:

把它放在Path变量的第一个位置:

%JAVA_HOME%\bin;...

instead ... another values added to your Path.

而是...添加到您的路径的另一个值。

I assuming that JAVA_HOME is defined as a variable.

我假设JAVA_HOME被定义为变量。

After this reopen console and check:

重新打开控制台并检查后:

java -version

#2


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时,它会查找你名为PATH的env变量中指定的所有路径,以及第一个匹配的地方,它会被拾取

so if you like command prompt to refer to jdk 6's Java append the path to PATH

所以如果你喜欢命令提示符来引用jdk 6的Java追加到PATH的路径

#3


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目录的路径。 java命令位于%JAVA_HOME%/ bin中

#4


Check your PATH environment variable also. Your system is referring to latest Java installation through PATH variable.

检查您的PATH环境变量。您的系统是指通过PATH变量进行的最新Java安装。

#5


I think in your path variable you have hardcoded the path to bin folder. it should always be %JAVA_HOME%/bin.

我认为在你的路径变量中你已经硬编码了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变量中选择路径,并且您不需要每次都更改这两个变量。