Nb: Java_Home Should Point to a Jdk Not a Jre

JAVA_HOME should point to a JDK not a JRE

Control Panel -> System and Security -> System -> Advanced system settings -> Advanced -> Environment Variables -> New System Variable

enter image description here

Maven installation issues: JAVA_HOME should point to a JDK not JRE?

OK, take a deep breath, and we'll walk through this. Each of these environment variables has a purpose, and once you understand what those purposes are, this makes a lot more sense. Mixing tutorials is not necessarily a problem, but you'll want to understand what you're doing, rather than just blindly copy values from the internet.

  1. JAVA_HOME is intended to identify to the system environment where to find a java runtime environment. It needs to be set to the full path of where your JDK has been installed. On windows, this might be C:\Program Files\Java\jdk-13.0.1. On a Linux system, you have a bit more flexibility. Common locations might be /opt/java/jdk-13.0.1 or /usr/local/java/jdk-13.0.1. If you installed your JDK somewhere else, then you need to use that path instead. The message NB: JAVA_HOME should point to a JDK not a JRE refers to a common mistake when installing maven -- maven requires a JDK, not a plain JRE. This error is so common that any time JAVA_HOME points to a folder that isn't a JDK, it prints this warning (even if the folder in question isn't actually a JRE).
  2. M2_HOME is supposed to be set to the full path where maven is installed (i.e. the place where you unzipped it). This more or less helps maven "find itself" if it should need to for whatever reason. Strictly speaking, this one isn't necessary. (It's not set on my system, and maven works fine for me). It's mostly a convenience for setting the next environment variable.
  3. M2 is the full path to the folder where the maven executable is. This will almost always be $M2_HOME/bin, but it's certainly possible to do weird things, and this will let you work around those situations. Obviously, this won't work if you didn't specify $M2_HOME. This one isn't strictly necessary, either, and is mostly a convenient way of setting up the next one.
  4. PATH is where your Linux system looks to find programs to run when you type their name on the command line. For ease of use, you'll want to make sure that the maven and java executables are included somewhere in the : delimited list. Most Linux distributions already have a default PATH set up for you in a shell resource file of some kind. You'll want to refer to their documentation for how to add another entry to the path, but a common idiom would be PATH=$PATH:$M2 (which would append the value of $M2 to the value of $PATH and then store the result back into PATH. If you didn't set up $M2 or $M2_HOME, you'll need to do something else.

So, TL;DR, if you installed your JDK in /opt/java/jdk-13.0.1 and unzipped maven into /opt/maven/apache-maven-3.6.3, your bear minimum working values are:

export JAVA_HOME=/opt/java/jdk-13.0.1
export PATH=$PATH:$JAVA_HOME/bin:/opt/maven/apache-maven-3.6.3/bin

And if you wanted a complete set

export JAVA_HOME=/opt/java/jdk-13.0.1
export M2_HOME=/opt/maven/apache-maven-3.6.3
export M2=$M2_HOME/bin
export PATH=$PATH:$JAVA_HOME/bin:$M2

It's worth noting that most Java IDEs will include a GUI for setting up maven and Java within the IDE (the settings will typically only work within that IDE). It's often much easier for beginners to get up and running that way.

JAVA_HOME should point to a JDK not a JRE + JAVA_HOME is not defined correctly

JAVA_HOME sould point to the base installation dir of java:
/usr/lib/jvm/java-11-openjdk-amd64/ not /usr/bin/java which probably is a symbolic link to /usr/lib/jvm/java-11-openjdk-amd64/bin/java

then in PATH variable you append $JAVA_HOME/bin

So it should look something like this:

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

FYI update-alternatives is only responsible for changing the symlink of java to point it to different versions of the executable,
think of it as a simple ln -s /usr/lib/jvm/java-11-openjdk-amd64/bin/java /usr/bin/java

Why does my JAVA_HOME point to jre instead of jdk?

Found the Solution myself:

sudo archlinux-java set <target java package name>

For Example:

sudo archlinux-java set java-15-jdk

Found this here: https://www.debugpoint.com/2021/02/install-java-arch/

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

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


Related Topics



Leave a reply



Submit