# Jenkins Upgrade and using 2 different Java versions

**URL:** <https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571>\
**Category:** Ask a question\
**Tags:** java\
**Created:** [February 17, 2022, 2:36pm UTC](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571 "2022-02-17T14:36:02Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![MarkEWaite](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/markewaite/32/20_2.png) [@MarkEWaite](https://community.jenkins.io/u/MarkEWaite)\
**Post date:** [February 18, 2022, 1:16pm UTC](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571/4 "2022-02-18T13:16:39Z")

</div>

> [@Marco](#):
>
> Okay, so that means for the first upgrade step I will use the official docker-tag “jenkins/jenkins:2.319.3-lts”. And then for the second upgrade step I will use the official docker-tag “jenkins/jenkins:2.319.3-lts-jdk11”.  
> Is it right?

Almost. If you want to stay on JDK 8 in order to reduce the size of each step of the upgrade, then you would use `jenkins/jenkins:2.319.3-jdk8` as the Docker container for the first step. After that first step of the upgrade is complete, you would upgrade to Java 11 by using the `jenkins/jenkins:2.319.3` container or its more precisely labeled alias `jenkins/jenkins:2.319.3-jdk11`.

> [@Marco](#):
>
> It is possible directly go to “jenkins/jenkins:2.319.3-lts-jdk11”?

Yes, if you don’t mind making a larger upgrade step, then you can go directly to JDK 11.

> [@Marco](#):
>
> Regarding the Jenkins-Agent, this is overheaded for us, because we need this JDK-8 only temporary until all our Jenkins-Pipeline are able to use JDK-11. In time we speak about one month or so, after that everything should running on JDK-11 and we don’t need JDK-8 anymore.

Even if you don’t need JDK 8 any longer, you should prefer to have no executors on the controller and configure agents to execute the jobs. See the article on controller isolation for the list of reasons

> **[Controller Isolation](https://www.jenkins.io/doc/book/security/controller-isolation/#not-building-on-the-built-in-node)**
>
> Jenkins – an open source automation server which enables developers around the world to reliably build, test, and deploy their software

> [@Marco](#):
>
> The following procedure is still possible with the “jenkins/jenkins:2.319.3-lts-jdk11”, right?
> 
> → [Making jenkins and maven use different java versions - Stack Overflow](https://stackoverflow.com/questions/41401055/making-jenkins-and-maven-use-different-java-versions#:~:text=Within%20Jenkins%20you%20can%20configure,a%20name%20on%20this%20page)
> 
> → [java - How to change the JDK for a Jenkins job? - Stack Overflow](https://stackoverflow.com/questions/28810477/how-to-change-the-jdk-for-a-jenkins-job).

Yes, Jenkins allows builds to run with many different JDK versions. We use Java 8, Java 11, and Java 17 regularly on [ci.jenkins.io](https://ci.jenkins.io/) with the controller running Java 11. There are many users that run multiple JDK versions with Jenkins jobs. It works very well.

This video includes an example that configures an Apache Maven tool to use a different JDK

[![](https://europe1.discourse-cdn.com/flex013/uploads/jenkins/original/2X/6/62e9c3af55b8ae3ee2a067939731409156e028db.jpeg "How to Configure Maven in Jenkins") ](https://www.youtube.com/watch?v=V-VFrYF_Z1Y&t=624s)

---

_[View the full topic](https://community.jenkins.io/t/jenkins-upgrade-and-using-2-different-java-versions/1571)._
