NB JAVA HOME should point to a JDK not a JRE The JAVA HOME environment variable is not defined correctly
Hi Guys, I have configured Maven in Jenkins. But it is showing me the below error when I tried to run any job.
[maven] $ /maven/bin/mvn -f pom.xml clean package
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
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
How can I solve this error?
You may get java_home should point to a jdk not a jre error if you didn't set your java path in .bashrc file. First try to check the Maven version using the below given command.
[root@localhost ~]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /maven
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_221-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-80.el8.x86_64", arch: "amd64", family: "unix"
You can see java home in your output. Copy the path till /usr/java/jdk1.8.0_221-amd64 and set this path in .bashrc file.
JAVA_HOME=/usr/java/jdk1.8.0_221-amd64