I am running Jenkins on a Windows 2021 R2 server. Jenkins is telling me "You are running Jenkins on Java 1.8, support for which will end on or after June 21, 2022" and showing: java.runtime.version 1.8.0_144-b01
I have tried everything I can find to update the Java version on the server:
- Downloaded and Installed from Java
- Downloaded and Installed Java 11 from OpenJDK
- Downloaded and Installed Java SDK 11 from Oracle
When I run java-version on the server, I get:
openjdk 11.0.15 2022-04-19 OpenJDK Runtime Environment OpenLogic-OpenJDK (build 11.0.15 10-adhoc..jdk11u) OpenJDK 64-Bit Server VM OpenLogic-OpenJDK (build 11.0.15 10-adhoc..jdk11u, mixed mode)
The java.library.path for Jenkins is:
C:\Program Files (x86)\Jenkins\jre\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\OpenJDK\jdk-11.0.15.10-hotspot\bin;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\dotnet;C:\Program Files\Git\cmd;C:\Program Files\nodejs;C:\Users\jenkinsa.dotnet\tools;C:\Users\jenkinsa.dotnet\tools;.
I am not a Java expert, to say the least. Jenkins' documentation says to:
Upgrade the JVM on which Jenkins is running
Use a package manager to install the new JVM.
Make sure the default JVM is the newly installed version. If it is not, run systemctl edit jenkins and set either the JAVA_HOME environment variable or the JENKINS_JAVA_CMD environment variable.
However, I can't figure out how to determine the "default JVM".
JAVA_HOME is: C:\Program Files\OpenJDK\jdk-11.0.15.10-hotspot
JRE_HOME is: C:\Program Files\Java\jre1.8.0_181
I have no JENKINS_JAVA_CMD environment variable, and "systemctl" does not do anything.
No matter what I do, it keeps saying that it is running 1.8 on Jenkins. What am I missing or doing wrong?
CodePudding user response:
You can explicitly start Jenkins with a specified version of Java by running the Jenkins war file with that version. You will need the java.exe
of the JDK version you want to run in, after which you can assign it in your command. So assuming that you want to run Jenkins in JDK 11 and your java.exe is located in Tools\java11\bin\
, you could say:
Tools\java11\bin\java.exe -jar jenkins.war
And have Jenkins run with Java 11. You could add this to batch file to avoid repeating yourself.
CodePudding user response:
For Windows, the Java version is in C:\Program Files (x86)\Jenkins\jre. I made a backup of this folder, copied over the new Java folder that had been installed (C:\Program Files\Java\jdk-11.0.15), and everything is working now.