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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Ansible and the Pre-Container Arts
  • regreSSHion: Should We Panic About the New OpenSSH Vulnerability?
  • Getting Started With OCR docTR on Ubuntu
  • Linux Mint Debian Edition Makes Me Believe It’s Finally the Year of the Linux Desktop

Trending

  • Building Scalable and Resilient Data Pipelines With Apache Airflow
  • Apache Doris vs Elasticsearch: An In-Depth Comparative Analysis
  • Power BI Embedded Analytics — Part 2: Power BI Embedded Overview
  • *You* Can Shape Trend Reports: Join DZone's Software Supply Chain Security Research
  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
251.9K 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, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Ansible and the Pre-Container Arts
  • regreSSHion: Should We Panic About the New OpenSSH Vulnerability?
  • Getting Started With OCR docTR on Ubuntu
  • Linux Mint Debian Edition Makes Me Believe It’s Finally the Year of the Linux Desktop

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!