0

Here are the java home and path configs. Not sure why maven is not detecting the java home correctly. Installed java 11 and maven both via sdkman on MacBook. Thanks.

m-c02yw:~ vn$ echo $JAVA_HOME

/Users/vn/.sdkman/candidates/java/current


m-c02yw:~ vn$ echo $PATH


/Users/vn/.sdkman/candidates/maven/current/bin:/Users/vn/.sdkman/candidates/java/current/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/munki


m-c02yw:~ vn$ java -version
openjdk version "11.0.14" 2022-01-18 LTS
OpenJDK Runtime Environment Zulu11.54+23-CA (build 11.0.14+9-LTS)
OpenJDK 64-Bit Server VM Zulu11.54+23-CA (build 11.0.14+9-LTS, mixed mode)


m-c02yw:~ vn$ $JAVA_HOME/bin/javac -version
javac 11.0.14


m-c02yw:~ vn$ mvn -version
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

2 Answers 2

1

update sdkman

$ sdk update

and then re-install java using sdkman-cli solved my problem

$ sdk install java
0

mvn is loading its java_home from ~/.mavenrc

cat $HOME/.mavenrc JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

Changed it here and my issue got fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.