Error Maven runs with the wrong JDK on Jenkins

+1 vote

When I run my Jenkins Maven project, I get the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myProject: Fatal error compiling: invalid target release: 1.8 -> [Help 1]

This shows that Maven is using Java 1.8 but it is supposed to use Java 1.7.

I run Maven in debug mode and it showed me the right versions:

...
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 14:51:28+0100)
Maven home: /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/maven305
Java version: 1.7.0_71, vendor: Oracle Corporation
Java home: /var/lib/jenkins/tools/hudson.model.JDK/JDK_7u71/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.8.0-44-generic", arch: "amd64", family: "unix"
...
The Jenkins server runs with Java 1.8
...
$ java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
...
$ javac -version
javac 1.8.0_74
...

Is there a simple solution to this?

Aug 8, 2018 in Jenkins by Tyrion anex
• 8,700 points
6,992 views

1 answer to this question.

0 votes

Perform the following steps:

1) Navigate to Manage Jenkins -> Configure system

2) Add JAVA_HOME and its path in Global Properties -> Environment Variables

3) Add JDK and path in JDK section

answered Aug 8, 2018 by Sophie may
• 10,620 points

Related Questions In Jenkins

0 votes
1 answer

Getting below error on Jenkins while creating a Maven Build Job

When you are using ssh to connect, ...READ MORE

answered Sep 3, 2019 in Jenkins by Hari
2,253 views
0 votes
1 answer

How to deploy the war file in Tomcat Server with Jenkins pipeline job on an windows machine?

Use deploy to container plugin. Go to the ...READ MORE

answered Sep 30, 2020 in Jenkins by Adil Abdullah Khan
4,634 views
0 votes
1 answer

Error while communicating with remote Oracle DB through Jenkins-CI

I was also facing the same problem. ...READ MORE

answered Apr 25, 2018 in Jenkins by shubham
• 7,340 points
1,078 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
+2 votes
1 answer
0 votes
1 answer

I’m facing a login error when I try to run Jenkins on Docker. How do I solve this?

You have to open the /var/log/jenkins/jenkins.log file to ...READ MORE

answered Jul 24, 2018 in Jenkins by Sophie may
• 10,620 points
3,575 views
0 votes
5 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP