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,270 points
528 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
• 9,530 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 in Jenkins by Hari
29 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
• 6,890 points
75 views
0 votes
2 answers

will running multiple Jenkins masters on same host increase the performance?

While using one big master, u can ...READ MORE

answered Aug 7, 2018 in Jenkins by Kalgi
• 40,460 points
547 views
+13 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,380 points
152 views
0 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
• 9,530 points
242 views
0 votes
5 answers