Search code examples
javamavenpathjava-home

Maven Java Home Path: \bin, or not to \bin


So I find myself kind of stuck in between.

I set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_121 then Maven works but

java -version

shows 'java' is not recognized as an internal or external command, operable program or batch file.

If I set JAVA_HOME to C:\Program Files\Java\jdk1.8.0_121\bin, Maven doesn't work but at least I get java -version right.

I'm pretty sure I'm doing something fundamentally wrong but I can't put my finger on it, obviously :(


Solution

  • java -version will look at your $PATH, so normally we need to add %JAVA_HOME%/bin to $PATH for any ad-hoc command. For maven, internally it checks $JAVA_HOME/bin. Hope it helps.