2

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.

Scott.F
  • 57
  • 1
  • 11

1 Answers1

8

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • That worked! Thank you. I read on one of the other posts to reference /bin. The main folder makes a lot more sense – Scott.F Sep 23 '18 at 04:51
  • 1
    Which one? There are a lot of incorrect answers in StackOverflow, but the unless someone points them out, we can't "stomp" them. – Stephen C Sep 23 '18 at 04:53
  • https://stackoverflow.com/questions/23619545/how-to-correct-java-home-which-should-point-to-a-jdk-not-a-jre-folder This was the post. However a correct answer wasn't selected so it definitely lowered the chance of that being right in the first place (its method 2 of the 2nd post) – Scott.F Sep 23 '18 at 05:06