'Upgrading Jenkins Java version from 8 to 11
I'd like to upgrade java from 8 to 11 as recommended for Jenkins 2.303.1, I'm reading the guide in https://www.jenkins.io/doc/administration/requirements/upgrade-java-guidelines/, but I don't know what to do in step:
Use a package manager to install the new JVM. Make sure the default JVM is the newly installed version. If it is not, use the correct java command in the Jenkins startup scripts (/etc/default/jenkins or /etc/init.d/jenkins).
does it mean install Java 11 and set java 11 is default one?
Solution 1:[1]
However you have (OpenJDK) 11 installed, as long as you have either JAVA_HOME=/path/to/jdk11
and PATH=$JAVA_HOME/bin:$PATH
or explicitly run /path/to/jdk11/bin/java -jar jenkins.war
or if you type java -version
and it returns "11", you are fine.
Note: that is to launch jenkins. You can set the JDK available to your jenkins jobs from within Manage | Global Tools Configurationtion.
2nd Note (updated): the documentation has been updated (2021-09-16) ... The default Docker image jdk as of 2.303.1 is now 11, so you don't need to append ”-jdk11", rather users must append "-jdk8" if users want to stick to 8.
Solution 2:[2]
You have two options: You can globally install Java 11 on your system, for example using a package manager like apt
. You would then make Java 11 your default Java.
The other option is to manually install Java, for example OpenJDK, and extract it to, for example, /opt/java
and adjust the Jenkins startup script to use that specific Java installation.
Solution 3:[3]
I just upgraded a Jenkins installed from apt packages (from: http://pkg.jenkins-ci.org/debian/) with the following steps (inspired by: https://www.jenkins.io/doc/book/installing/linux/)
First, install java 11:
sudo apt install openjdk-11-jre
Then check java -version
which may still show openjdk version "1.8.[x]"
If so, do choose a java-11
alternative with:
update-alternatives --config java
Then java -version
should show openjdk version "11.0.[x]"
Then you can do:
systemctl restart jenkins
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Thomas |
Solution 3 | GregOriol |