JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

huangapple go评论97阅读模式
英文:

JAVA_HOME env still not defined correctly windows 10

问题

以下是您的内容的翻译:

最近,我一直在尝试使用Maven设置一个项目。在安装二进制文件后,我通过将M2_HOME添加为变量名称,C:\Program Files\apache-maven-3.9.2作为变量值添加到我的系统环境变量中,将它添加到了我的路径中。确认一下,这确实存在:

JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

然后,我还将JAVA_HOME添加为变量名称,并将C:\Program Files\Java\jdk-19作为变量值添加到我的系统环境变量中:

JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

现在,无论我尝试在终端中以管理员身份运行mvn -version还是mvn,都会得到以下错误信息:

C:\Users444>mvn -verison
JAVA_HOME环境变量未正确定义,
需要此环境变量才能运行此程序。

C:\Users444>

注意:在我添加JAVA_HOME之前,当我运行mvn package时,我得到一个编译错误,说编译器没有配置好,这意味着Maven已安装并正常工作。所以我决定添加JAVA_HOME,但现在它完全停止工作了,原因不明。

其他注意事项:
我在系统路径中有这两个值:

JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

我尝试过:

  • 删除两个环境变量然后重新添加它们
  • 完全重新安装Maven并再次按照步骤操作

任何帮助将不胜感激:)

更新:我的路径:
JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

更新:g00se的请求:

C:\Users444>echo %JAVA_HOME%
C:\Program Files\Java\jdk-19\bin

C:\Users444>echo %PATH%
C:\Program Files\apache-maven-3.9.2\bin;C:\Program Files\Java\jdk-19\bin;C:\Program Files (x86)\OpenJDK\jre-8.0.292.10-hotspot\bin;C:\Program Files\OpenJDK\jdk-8.0.292.10-hotspot\bin;C:\Program Files (x86)\OpenJDK\jdk-8.0.362.09-hotspot\bin;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\MinGW\bin;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\Users444\AppData\Local\Programs\Python;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Program Files (x86)\dotnet\;C:\Program Files\Java\jdk-19\bin;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC0\Tools\Binn\;C:\Program Files\Git\cmd;C:\Users444\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users444\AppData\Local\Programs\Python\Python310\;C:\Users444\AppData\Local\Microsoft\WindowsApps;C:\Users444\AppData\Local\atom\bin;C:\Users444\.dotnet\tools;C:\Users444\AppData\Local\Programs\Fiddler;C:\Users444\AppData\Roaming\npm;";C:\Program Files\nodejs\";C:\Users444\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users444\AppData\Local\GitHubDesktop\bin;C:\Users444\.dotnet\tools;C:\Program Files\MongoDB\Server.0\bin;C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.2\bin;;C:\Program Files\apache-maven-3.9.2\bin;C:\Program Files\Java\jdk-19\bin;

C:\Users444>mvn -version
JAVA_HOME环境变量未正确定义,
需要此环境变量才能运行此程序。

C:\Users444>

更新:从我的环境变量中删除JAVA_HOME(无论是系统还是用户环境变量)会导致此屏幕显示:
JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

但添加JAVA_HOME会导致它出现问题。为什么?

另外,我尝试了以下一系列命令:
JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

希望这能帮助您解决问题。

英文:

So recently I've been trying to set up a project using maven. After I installing the binary zip, I added it to my path by adding M2_HOME as a var name and C:\Program Files\apache-maven-3.9.2 as the var value in my System Environment Variables. To confirm, this does exist:

JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

Then I added JAVA_HOME as a var name and C:\Program Files\Java\jdk-19 as the var value to my System Env Variables as well:

JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

Now, whenever I try running mvn -version or even mvn from terminal that is ran as admin and without admin permissions, I get:

C:\Users444>mvn -verison
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.

C:\Users444>

Note: Before I added JAVA_HOME, when I ran mvn package I got a compilation error saying that the compiler wasn't figured, meaning that marven was installed and working. So I decided to add JAVA_HOME and now it fully stopped working for some reason.

Other Note:
I have these two values in System Path:

JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

I tried:

Removing both environment variables and re-adding them
Fully re-installing Maven and following the steps agains

Any help would be appreciated JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

Edit: My Path:
JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

Edit: Request by g00se:

C:\Users444>echo %JAVA_HOME%
C:\Program Files\Java\jdk-19\bin

C:\Users444>echo %PATH%
C:\Program Files\apache-maven-3.9.2\bin;C:\Program Files\Java\jdk-19\bin;C:\Program Files (x86)\OpenJDK\jre-8.0.292.10-hotspot\bin;C:\Program Files\OpenJDK\jdk-8.0.292.10-hotspot\bin;C:\Program Files (x86)\OpenJDK\jdk-8.0.362.09-hotspot\bin;C:\Program Files (x86)\Razer\ChromaBroadcast\bin;C:\Program Files\Razer\ChromaBroadcast\bin;C:\MinGW\bin;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\Users444\AppData\Local\Programs\Python;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\Program Files (x86)\dotnet\;C:\Program Files\Java\jdk-19\bin;C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft SQL Server0\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC0\Tools\Binn\;C:\Program Files\Git\cmd;C:\Users444\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users444\AppData\Local\Programs\Python\Python310\;C:\Users444\AppData\Local\Microsoft\WindowsApps;C:\Users444\AppData\Local\atom\bin;C:\Users444\.dotnet\tools;C:\Users444\AppData\Local\Programs\Fiddler;C:\Users444\AppData\Roaming\npm;";C:\Program Files\nodejs\";C:\Users444\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users444\AppData\Local\GitHubDesktop\bin;C:\Users444\.dotnet\tools;C:\Program Files\MongoDB\Server.0\bin;C:\Program Files\JetBrains\IntelliJ IDEA 2023.1.2\bin;;C:\Program Files\apache-maven-3.9.2\bin;C:\Program Files\Java\jdk-19\bin;

C:\Users444>mvn -version
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.

C:\Users444>

UPDATE:
Removing JAVA_HOME from my environment vars in both system and user result in this screen:
JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

But adding JAVA_HOME breaks it. Why?

Also there's these following sequence of commands I tried:
JAVA_HOME 环境变量在 Windows 10 上仍未正确定义。

答案1

得分: 0

修复:
不要像我一样傻瓜,仔细检查你的JDK。尽管我在Program Files中安装了jdk-19,但它只有一个文件夹,lib,里面是空的

我做了什么:

我只是删除了那个并安装了最新的JDK(jdk-20),尽管如果你像我一样是个傻瓜,只需重新安装JDK。

英文:

Fix:
Don't be an idiot like me, double check your JDK. Although I had a jdk-19 installing in my Program Files, it only had 1 folder, lib, which was empty

What I did:

I just removed that and installed latest JDK (jdk-20) although just reinstall JDK if you're an idiot like me

huangapple
  • 本文由 发表于 2023年6月6日 14:30:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76411967.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定