[英]Why there are two java path in my PC when i use the “mvn -v”
When I use mvn spring-boot:run
to run a Spring Boot project, I find if use the command in Cmd
, it works. 当我使用mvn spring-boot:run
运行一个Spring Boot项目时,我发现是否使用Cmd
的命令,它可以工作。 but if I use it in Git Bash
, it can't work. 但是如果我在Git Bash
使用它,它将无法正常工作。
So I use java -version
and mvn -v
to view the Java and maven version. 因此,我使用java -version
和mvn -v
来查看Java和maven版本。
java -version
give me the same result, but mvn -v
result is different, as the picture shows: java -version
给我相同的结果,但是mvn -v
结果不同,如图所示:
And when I see my java path, I'm sure it's C:\\Program Files\\Java\\jdk1.8.0_151
当我看到我的java路径时,我确定它是C:\\Program Files\\Java\\jdk1.8.0_151
So I want to know, why there are two Java paths in my PC when I use mvn -v
? 所以我想知道,当我使用mvn -v
时,为什么我的PC中有两个Java路径?
Both the java
executable and Maven by default use the JDK that is specified in the $JAVA_HOME
environment variable. 默认情况下, java
可执行文件和Maven都使用$JAVA_HOME
环境变量中指定的JDK。
You are executing java
and Maven ( mvn
) in different environments ( cmd.exe
in one case and Git Bash in the other case), so the most likely explanation is that $JAVA_HOME
is set to different JDKs in the respective environments. 您正在不同的环境中执行java
和Maven( mvn
)(一种情况下执行cmd.exe
,另一种情况下执行Git Bash),因此最可能的解释是$JAVA_HOME
被设置为各自环境中的不同JDK。
You can check the content of $JAVA_HOME
with echo $JAVA_HOME
. 您可以使用echo $JAVA_HOME
检查$JAVA_HOME
的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.