简体   繁体   中英

JAVA_HOME is not defined correctly. ubuntu

When I check maven Version

$ mvn -version

Error: JAVA_HOME is not defined correctly.
  We cannot execute /usr/lib/jvm/java-8-oracle/bin/java

How to solve it ? these are my java jdk version.

$ java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)


$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle

Make sure your JAVA_HOME variable is set to the JRE folder, like this:

/usr/lib/jvm/java-8-oracle/jre

To further improve your setup, you can let Java pick the correct version by putting this in your JAVA_HOME (this assumes you used the Oracle installer):

export JAVA_HOME=$(/usr/libexec/java_home)

If this doesn't work for you, make sure permissions are set correctly (Execute permissions on the binaries)

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