Maven "JAVA_HOME should point to a JDK not a JRE"
May be java path configuration missing. You can follow this steps:
- Create or export JAVA_HOME="JDK directory" . Ex. "C:\Program Files\Java\jdk1.8.0_65"
- Create or export Path variable for PATH="JDK Bin DIrectory" . Ex. "C:\Program Files\Java\jdk1.8.0_65\bin"
- Run command java -version from your terminal.Check it is correct or not.
Then configure maven. follow these steps : You can try to install maven globaly. you can skip these steps if already configured.just for check run mvn --version command for checking maven is installed correctly.
Download maven from maven download link
Create or export M2_HOME="MAVEN ROOT LOCATION". Ex. : E:\SoftwareRepo\building tools\apache-maven-3.5.2
Create or export MAVEN bin folder location to PATH variable. For example: E:\SoftwareRepo\building tools\apache-maven-3.5.2\bin
Open terminal or cmd and run mvn --version to confirm maven is installed or not.
Related videos on Youtube
david
I have a passion for software development. Always trying to keep up with the new technologies.
Updated on January 12, 2021Comments
-
david over 3 years
I had the following command working fine with OpenJDK
mvn clean install
I then uninstalled OpenJDK and installed Oracle JDK 8, and now when I run
mvn clean install
The JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE
I'm running Linux Mint 19, I did run into a few Stackoverflow questions related to the issue. Most where related to Windows and some that were related to Linux. The Linux ones recommended to run
sudo update-alternatives --config java
but in my case I get
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-oracle/jre/bin/java Nothing to configure.
Any idea how I can make
mvn clean install
work again?-
david over 5 years@ElliottFrisch I had accidentally pasted the wrong thing in my question. I fixed it.
mvn clean install
saysThe JAVA_HOME environment variable is not defined correctly This environment variable is needed to run this program NB: JAVA_HOME should point to a JDK not a JRE
-
Scary Wombat over 5 yearsJava home should be
/usr/lib/jvm/java-8-oracle/jdk
- check that it exists -
david over 5 years@ScaryWombat I don't see jdk. I have
bin lib src.zip COPYRIGHT LICENSE THIRDPARTYLICENSEREADME-JAVAFX.txt include man THIRDPARTYLICENSEREADME.txt javafx-src.zip README.html jre release
-
Henry over 5 yearsDo you have a directory
/usr/lib/jvm/java-8-oracle/bin
that contains among othersjava
andjavac
? If yes, set JAVA_HOME to/usr/lib/jvm/java-8-oracle
. -
david over 5 years@Henry I do, how do I set JAVA_HOME?
-
Scary Wombat over 5 yearsYes I do not think you have a JDK installed - try again
-
david over 5 yearsI just uninstalled Oracle Java and installed
openjdk-11-jdk
using apt. I am sure it's installed. But Maven still gives the same error -
Henry over 5 yearsto set an evironment variable in the current shell use something like
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
. To set it permanently check the conventions of your Linux distribution.
-