NB JAVA HOME should point to a JDK not a JRE The JAVA HOME environment variable is not defined correctly

0 votes

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?

Jun 4, 2020 in DevOps & Agile by akhtar
• 38,170 points
7,244 views

1 answer to this question.

0 votes

Hi@akhtar,

You may get this error if you didn't set your java path in .bashrc file. First try to check 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
answered Jun 4, 2020 by MD
• 95,180 points

Related Questions In DevOps & Agile

+13 votes
2 answers
+1 vote
2 answers

is it possible to assign a Feature/User Story/Task to a team [Group] in VSTS

In most cases, we would break Work ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
3,125 views
+3 votes
2 answers
+1 vote
2 answers

Should I commit Terraform State files to the git repository?

Its better not to commit it to ...READ MORE

answered Aug 3, 2018 in DevOps & Agile by Nilesh
• 7,020 points
1,633 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,066 views
+2 votes
1 answer
0 votes
1 answer

How to get the file count in amazon bucket linux cli

Hi@Shahzeb, You can do this task using the ...READ MORE

answered Apr 27, 2020 in DevOps & Agile by MD
• 95,180 points
858 views
+2 votes
1 answer

Error: You might need to start Docker for Windows. How do i start the daemon?

Hi, If you are running containers with Docker, ...READ MORE

answered May 19, 2020 in DevOps & Agile by MD
• 95,180 points
5,347 views