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

如何在最新版Jenkins中添加JDK 11以构建Java应用

Hey there! Let's figure out why Jenkins isn't showing your OpenJDK 11 in the dropdown, even after you've downloaded it and added the JDK_HOME in global config. Here are the steps to troubleshoot and fix this:

1. Double-check your Global Tool Configuration for JDK

First, head back to Manage Jenkins > Global Tool Configuration (the spot where you added the JDK entry). Make sure you’ve got this set up right:

  • Uncheck the Install automatically box (since you manually downloaded and extracted the JDK yourself)
  • Give it a clear, recognizable name like OpenJDK 11—this is what will pop up in the project dropdown later
  • Verify the JAVA_HOME path is absolute and error-free (e.g., /opt/openjdk-11). Double-check there are no typos, and that the directory actually has the JDK files (like the bin/java executable)
  • Don’t forget to hit Save at the bottom! It’s super easy to skip this step and wonder why nothing changes.
2. Make sure Jenkins can access the JDK directory

Even if the path is correct, the Jenkins user might not have permission to read the JDK folder. Let’s confirm:

  • SSH into your Jenkins server
  • Switch to the Jenkins user with su - jenkins (or sudo -u jenkins bash if su doesn’t work)
  • Navigate to the JDK’s bin directory and run ./java -version
    • If this spits out the OpenJDK 11 version info, you’re good—permissions are sorted.
    • If you get a "permission denied" error, fix it with sudo chown -R jenkins:jenkins /path/to/openjdk-11 and try again.
3. Refresh your project configuration page

After saving the global JDK config, go back to your project’s settings. Sometimes the dropdown doesn’t update right away—try refreshing the browser tab, or even logging out and back into Jenkins if needed. Your OpenJDK 11 entry should now show up in the "JDK" dropdown under the project’s build environment.

4. Check if the JDK Tool Plugin is enabled

While latest Jenkins versions include this by default, it’s worth a quick check:

  • Go to Manage Jenkins > Plugins > Installed Plugins
  • Search for JDK Tool Plugin
  • Make sure it’s checked and enabled. If it’s missing, install it and restart Jenkins.
5. Restart Jenkins as a last resort

If all the above steps don’t work, a quick restart might clear any cached tool configurations. You can do this via:

  • The Jenkins UI: Go to Manage Jenkins > Restart Jenkins
  • Or command line: sudo systemctl restart jenkins (if using systemd) or sudo service jenkins restart

Once you’ve worked through these steps, your OpenJDK 11 should appear in the dropdown menu for your project’s build configuration.

内容的提问来源于stack exchange,提问作者LppEdd

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.12 04:23:50