问题
java -version
执行正常找到JDK
mvn -v
命令执行完出错:
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
具体报错如下:
Microsoft Windows [版本 10.0.22621.4317]
(c) Microsoft Corporation。保留所有权利。
C:\Users\xxx>java -version
java version "17.0.8" 2023-07-18 LTS
Java(TM) SE Runtime Environment (build 17.0.8+9-LTS-211)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS-211, mixed mode, sharing)
C:\Users\xxx>mvn -v
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
C:\Users\xxx>
解决
参考了网上很多解决方法 && AI解答,没有实质性解决,最后根据这些方法大致得到原因,下面是解决的方法