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.

Naman
  • 27,789
  • 26
  • 218
  • 353
LppEdd
  • 20,274
  • 11
  • 84
  • 139

2 Answers2

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

BSMP
  • 4,596
  • 8
  • 33
  • 44
kasul
  • 776
  • 6
  • 4
  • 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 '19 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 '19 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 https://groups.google.com/forum/#!topic/zaproxy-jenkins/w5m9stza7pU – Israel Perales May 08 '19 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. – Thomas Upton Jun 03 '19 at 21:20
  • You cannot upgrade your jdk11 version with that method (replace with 11.0.6 in the url doesn't work). And the link given by oracle requires authentication, you cannot paste the url . – pdem Jan 27 '20 at 16:21
  • I tried this but I get ```Installer "Extract *.zip/*.tar.gz" cannot be used to install "Java SDK 11" on the node "Jenkins"``` – Giuseppe Salvatore Apr 04 '20 at 16:37
  • @Giuseppe, the download-link appears to be from a time when java 11 hadn't entered LTS; https://jdk.java.net/java-se-ri/11 which will provide 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 is: https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz – cueedee Apr 05 '20 at 13:13
  • I had provided my previous comment as an additional answer, but this got moderated into deletion. – cueedee Apr 05 '20 at 13:23
  • 1
    The "JDK Tool Plugin" is now called "Oracle Java SE Development Kit Installer": https://plugins.jenkins.io/jdk-tool/ – user1364368 Aug 06 '20 at 10:34
  • Thanks this has saved me a lot of time. For reference, this link contains the jdk archive versions at time of writing. https://jdk.java.net/archive/ – JeanCarlos Chavarria May 18 '22 at 22:53
  • for jdk 17 you can use https://download.java.net/openjdk/jdk17/ri/openjdk-17+35_linux-x64_bin.tar.gz – kesaven Dec 11 '22 at 16:40
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
Gayan Weerakutti
  • 11,904
  • 2
  • 71
  • 68