DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • My Dive into Local LLMs, Part 1: From Alexa Curiosity to Homegrown AI
  • Ansible and the Pre-Container Arts
  • regreSSHion: Should We Panic About the New OpenSSH Vulnerability?
  • Getting Started With OCR docTR on Ubuntu

Trending

  • Throughput vs Goodput: The Performance Metric You Are Probably Ignoring in LLM Testing
  • RAG Done Right: When to Use SQL, Search, and Vector Retrieval and How To Combine Them
  • Detecting Bugs and Vulnerabilities in Java With SonarQube
  • No More Cheap Claude: 4 First Principles of Token Economics in 2026
  1. DZone
  2. Coding
  3. Frameworks
  4. Installing OpenJDK 11 on Ubuntu 18.04

Installing OpenJDK 11 on Ubuntu 18.04

OpenJDK 11 was released this past week. Let's take a look at how to install OpenJDK 11 on Ubuntu 18.04, as well as new features in the JDK.

By 
Laszlo Csontos user avatar
Laszlo Csontos
·
Updated Oct. 01, 18 · Tutorial
Likes (12)
Comment
Save
Tweet
Share
252.4K Views

Join the DZone community and get the full member experience.

Join For Free

OpenJDK 11 was released on September 25, 2018. As this is the first LTS release after version 8, it's been a long time coming. After having it installed on Ubuntu 18.04 (Bionic Beaver), which comes with a package named openjdk-11-jdk, to my surprise, that was still part of an earlier version (Java 10).

SRU Exception for OpenJDK

The Ubuntu Foundation Team made an SRU exception for OpenJDK. Although version 10 is a non-LTS release, they've packaged it as openjdk-11-jdk until OpenJDK 11 goes GA. This choice was based on that assumption that there is a much smaller interface delta between releases 10 and 11 than it would be between 8 and 11.

That's a fairly good reasoning and perhaps an apt-get upgrade wouldn't screw things up that badly when OpenJDK's version gets bumped up from 10 to 11.

There's one area tiny though where there's a significant difference between 10 and 11— Flight Recorder is now open source. OpenJDK 10 doesn't contain the flight recorder. At that time, it was a commercial feature of Oracle JDK, but OpenJDK 11 comes with it.

As a consequence, installing openjdk-11-jdk doesn't allow applications to be instrumented with JFR, as the JVM options used to enable it simply aren't getting recognized by OpenJDK 10. In fact, the JVM fails to start and complains about unrecognized options.

Installing Ubuntu's Default JDK

This is very simple, you just need the following package.

% apt-get install default-jdk


Nevertheless, be sure to check what Java version that actually installs.

$ java -version
openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.2)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.2, mixed mode)


Installing OpenJDK Manually

That's easy, too — you just have to download a tarball and extract it somewhere.

% wget https://download.java.net/java/GA/jdk11/28/GPL/openjdk-11+28_linux-x64_bin.tar.gz -O /tmp/openjdk-11+28_linux-x64_bin.tar.gz
% sudo tar xfvz /tmp/openjdk-11+28_linux-x64_bin.tar.gz --directory /usr/lib/jvm
% rm -f /tmp/openjdk-11+28_linux-x64_bin.tar.gz


That's going to be OpenJDK 11for real.
$ /usr/lib/jvm/jdk-11/bin/java -version
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)


Switching Between JDKs

I would prefer to use the distro's JDK as long as it works for the task at hand. In this case, that isn't an option, not yet at least. For that reason, I'm using the alternatives framework, which makes it possible to switch between JDKs easily.

% sudo sh -c 'for bin in /usr/lib/jvm/jdk-11/bin/*; do update-alternatives --install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done'
% sudo sh -c 'for bin in /usr/lib/jvm/jdk-11/bin/*; do update-alternatives --set $(basename $bin) $bin; done'


Once OpenJDK 11 appears in Ubuntu 18.04, it's just going to be a matter of a package upgrade and which alternative switches to use.

% sudo apt-get install --only-upgrade default-jdk
% update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1101      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1101      manual mode
* 2            /usr/lib/jvm/jdk-11/bin/java                  100       manual mode

Press <enter> to keep the current choice[*], or type selection number:
OpenJDK ubuntu

Published at DZone with permission of Laszlo Csontos. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • My Dive into Local LLMs, Part 1: From Alexa Curiosity to Homegrown AI
  • Ansible and the Pre-Container Arts
  • regreSSHion: Should We Panic About the New OpenSSH Vulnerability?
  • Getting Started With OCR docTR on Ubuntu

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook