34

I need to build my application using Java 11.
However the dropdown menu stops at Java 9.

What do I do? OpenJDK is acceptable too.
I'm on the latest version of Jenkins.

Edit: as of now I've downloaded the binaries using wget, extracted them on the machine, and added a JDK JDK_HOME entry via Global Configurations.

4

2 Answers 2

63

I guess you are using the JDK Tool Plugin.

Click "Manage Jenkins" > "Global Tool Configuration" > "Add JDK" (near JDK installations)

Delete the java.sun.com installer. Just click "Add Installer" below and choose "Extract .zip/.tar.gz"

Enter following:

Label: openjdk-11

Download URL: https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz

Subdirectory of extracted archive: jdk-11.0.1 (Optional subdirectory of the downloaded and unpacked archive to use as the tool's home directory.)

And "Save" the configuration

=> Use JDK label (openjdk-11) in your build job.


The download-link given above appears to be from a time when java 11 hadn't entered LTS;

Instead go to Java Platform, Standard Edition 11 Reference Implementations which will provide you the download-link to the most recent release of the...

[...] official Reference Implementation for Java SE 11 (JSR 384) [...] based solely upon open-source code available from the JDK 11 Project in the OpenJDK Community. This Reference Implementation applies to both the Final Release of JSR 384 (Sep 2018) and Maintenance Release 1 (Mar 2019).

... which as of this writing is: https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz

11
  • Yes, I'm using that plugin! That's basically what I've manually done now. Good to know it can be automatized. Quick question. What if Jenkins lives in a Docker container and it is re-started? Does this method always download a fresh copy?
    – LppEdd
    Mar 19, 2019 at 15:37
  • 1
    Yes, until you use a persistent storage (mount point in container: /var/jenkins_home). Or maybe use a local web server for faster downloads of JDKs.
    – kasul
    Mar 19, 2019 at 15:50
  • 1
    For some reason when i put any string in label the installer can not execute and when keep the filed empty, works groups.google.com/forum/#!topic/zaproxy-jenkins/w5m9stza7pU May 8, 2019 at 18:18
  • 7
    The label field in this installer config is to restrict the labels that this jdk will be available on. Leave it empty to use it on all nodes. Jun 3, 2019 at 21:20
  • 1
    The "JDK Tool Plugin" is now called "Oracle Java SE Development Kit Installer": plugins.jenkins.io/jdk-tool Aug 6, 2020 at 10:34
9

JDKs can be managed with JDK Tool Plugin which usually comes pre-installed.

  • Go to "Manage Jenkins" > "Global Tool Configuration"

  • Under JDK installations click 'Add JDK'

  • Delete the default installer and add an installer of type "Extract .zip/.tar.gz"

  • Find a URL to a JDK archive in tar.gz or zip format.

OpenJDK 11 binary can be found in jdk.java.net/java-se-ri/11

This is the setting I have for openjdk-11+28

JDK name: OpenJDK-11
Label: (Keep this blank)
Download URL for binary archive: https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz

Subdirectory of extracted archive: jdk-11

Here in my case openjdk-11+28_linux-x64_bin.tar.gz, did contain a subdirectory named jdk-11

If it's incorrectly set up you might see the error:

Error: JAVA_HOME is not defined correctly.
  We cannot execute /var/jenkins_home/tools/hudson.model.JDK/JDK-11/bin/java
2
  • You can define the gradle task like this: build -x test -Dorg.gradle.java.home=<jdk11_path>
    – Manan Shah
    Apr 7, 2021 at 10:59
  • In my case jdk11_path ==> /root/.jenkins/tools/hudson.model.JDK/OpenJDK-11/jdk-11
    – Manan Shah
    Apr 7, 2021 at 11:00

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.