3

I have jdk 7 and 8 on my machine, JAVA_HOME points to java 7, and Jenkins uses java 8. I created a maven project and i am trying to build it on jenkins using java 8 but i get the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven-demo: Compilation failure -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

in pom.xml I added the following:

<properties>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>

and

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <verbose>true</verbose>
          <fork>true</fork>
           <source>1.8</source>
           <target>1.8</target>
          <executable>path/to/jdk/bin/javac</executable>
        </configuration>
      </plugin>
    </plugins>
</build>

but I still get the same error with either method of the 2 above.

How can I update it to make maven use java 8 ?

2
  • Did you actually update <executable> to point to your jdk8? Commented Feb 27, 2019 at 13:33
  • Yes I did, but it didn't work Commented Feb 27, 2019 at 13:36

1 Answer 1

7

You have to configure your Jenkins under Global Tool Configuration with Name and JAVA_HOME of your different jdks. http://path-to-your-jenkins:8080/configureTools/. Afterwards you can choose the JDK within your project configuration http://path-to-your-jenkins:8080/job/yourJob/configure. In the General tab in the field JDK.

Sign up to request clarification or add additional context in comments.

2 Comments

Wow the pointer to the General section was just what I needed
thanks , I also met this problem, that's helped me. I give a hit: add at lest two different java version in Global Tool Configuration,then the General tab will show the jdk select item

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.