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
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.
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 beC:\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 messageNB: 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 timeJAVA_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).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.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.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 defaultPATH
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 bePATH=$PATH:$M2
(which would append the value of$M2
to the value of$PATH
and then store the result back intoPATH
. 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
Springboot Data - No Property Registration Found
How to Modify a Field in Each Element of List in Java 8 Using Stream
Getting 400 for Spring Resttemplate Post
Mockito - Nullpointerexception When Stubbing Method
Could Not Open JPA Entitymanager for Transaction (Using Localcontainerentitymanagerfactorybean)
How to Pass List in Postman in Get Request and Get in Getmapping
Is There an Invisible Character That Is Not Regarded as Whitespace
How to Replace Multiple Words in a Single String in Java
How to Make Program to Continue Running After Exception
How to Get Numbers from Given Gcd and Lcm
How to Download Entire Folder Located on S3 Bucket
Jackson @Jsonproperty Not Working If Property Name Not Equal Field Name
Spring Boot JPA Unknown Column in Field List
On Selenium Webdriver How to Get Text from Span Tag
Spring Rest - Create Zip File and Send It to the Client
How to Store a String Longer Than 4000 Characters in an Oracle Database Using Java/Jdbc