Maven builds with wrong JDK on jenkins

In Jenkins 2.7.3 (and later on maybe) the menu navigation is slightly different:

1) Manage Jenkins

2) Global Tool Configuration

3) JDK section

4) press "JDK installations" button

5) JDK options and paths are there


Proper solution is to add needed JDK to Jenkins global configuration and then to specifically choose needed JDK version/installation under the project build configuration.

Start by copying needed JDKs to your build machine. Then open Jenkins configuration and scroll to "JDK" section [Jenkins -> Manage Jenkins -> Configure System]. Add desired JDKs to Jenkins. Following picture is example of Jenkins configured with two different JDKs.JDK installations under Jenkins

Now under project configuration [YourProject -> Configure], a new option will be available. You can select desired JDK to build project with as in the picture: enter image description here

"(Default)" JVM in picture refers to the JDK under which Jenkins run. Easy fix would be to change this JDK to the version needed for your project (either by changing Jenkins start script or using JAVA_HOME). This will work. However once you have a need to build two or more conflicting projects, you are gonna need to configure multiple JDKs anyway.

By using similar steps you can add multiple maven installations to your Jenkins server.