JAVA_HOME should point to a JDK not a JRE even though it points to a JDK

Scott.F :

Hello and thank you for any help you can provide.

I just upgraded to Ubuntu 18.04.1 and before the install my JAVA_HOME for my path was defined properly and worked successfully. However, I am now unable to use Maven due to the following error: "JAVA_HOME should point to a JDK not a JRE". I know this is a common problem and I tried a lot of potential solutions before making this post.

When I echo $JAVA_HOME, I get back /usr/lib/jvm/java-11-openjdk-amd64/bin which is what I set it to be in my .bashrc via the following lines:

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/bin
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH

From there, I also checked Which java where I got the output of /usr/bin/java. I checked further and found that readlink -f /usr/bin/java returns a value of /usr/lib/jvm/java-11-openjdk-amd64/bin/java. Again, this points to a JDK not a JRE.

I also attempted to fix the issue by configuring a java with sudo update-alternatives --config java and chose the value of /usr/lib/jvm/java-11-openjdk-amd64/bin/java

To top it all off, I have reinstalled java and maven and I have restarted my computer and command line multiple times.

VonC :

First, try and remove the /bin from your JAVA_HOME path.

You should reference the main folder of the JDK, not its bin/ subfolder.

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=115765&siteId=1