You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins 2.303.1从Java 8升级至Java 11的步骤疑问咨询

Answer to Your Jenkins Java Upgrade Question

Great question! Let me clarify what that official guideline step actually means—it’s not only "install Java 11 and set it as the default JVM", but rather gives you two valid paths to ensure Jenkins uses Java 11, depending on your system’s needs:

This is the simplest approach if your entire system doesn’t rely on Java 8 for other applications. Here’s how it works:

  • First, install Java 11 using your package manager (e.g., apt install openjdk-11-jdk on Debian/Ubuntu, yum install java-11-openjdk-devel on RHEL/CentOS).
  • Then set it as the default JVM using your distro’s alternatives tool:
    • For Debian/Ubuntu: Run sudo update-alternatives --config java and select the Java 11 entry from the list. Do the same for javac with sudo update-alternatives --config javac.
    • For RHEL/CentOS: Use sudo alternatives --config java and sudo alternatives --config javac instead.
  • Verify the change with java -version and javac -version—both should show Java 11.
  • Restart Jenkins, and it will automatically pick up the default Java 11.

Option 2: Configure Jenkins to use Java 11 without changing the system default

If you need to keep Java 8 as the system default (e.g., other apps depend on it), you can override the Java version just for Jenkins:

  • Locate Jenkins’ startup configuration file: this is usually /etc/default/jenkins (for systemd setups) or /etc/init.d/jenkins (older init systems).
  • Open the file and look for lines defining JAVA_HOME or JAVA. Update the path to point to your Java 11 installation directory. For example:
    JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
    
  • Save the file and restart Jenkins with sudo systemctl restart jenkins (or sudo service jenkins restart for older systems).
  • To confirm Jenkins is using Java 11, go to your Jenkins dashboard → Manage Jenkins → System Information, and check the java.version field.

To sum up the official guideline

The step is saying: Either set Java 11 as the system default (so Jenkins uses it automatically), or if you can’t/won’t change the default, explicitly tell Jenkins to use Java 11 via its startup script. Either way, the end goal is ensuring Jenkins runs on Java 11—you don’t have to do both, just pick the option that fits your system.

内容的提问来源于stack exchange,提问作者Tien Dung Tran

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 11:42:39