简体   繁体   中英

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. but if I use it in Git Bash , it can't work.

So I use java -version and mvn -v to view the Java and maven version.

java -version give me the same result, but mvn -v result is different, as the picture shows: 终端输出1

And when I see my java path, I'm sure it's C:\\Program Files\\Java\\jdk1.8.0_151

终端输出2

So I want to know, why there are two Java paths in my PC when I use mvn -v ?

Both the java executable and Maven by default use the JDK that is specified in the $JAVA_HOME environment variable.

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.

You can check the content of $JAVA_HOME with echo $JAVA_HOME .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM