What happened in "Java 8 to Java 11" and how to build an environment

Purpose of this article

――This article is for people who are absolutely addicted to "Building a Java environment" and are always confused by complicated information. ――Since 2017, Java has become a rapidly changing world. Recognizing this, we have compiled the information we have investigated so that we can understand the "core ideas" and "important trends." -** "I've been touching it for the first time in 5 years (Java | JVM language), but I don't understand the environment at all" ** or ** "What are you talking about, such as Corretto and AdoptOpenJDK?" ** In other words, the author (the author a while ago) aims to "get the basic knowledge so that he will never be addicted to it in the future." The following three books: --Rough history --Building a local development environment in 2020 --Source and reference URL --I will not touch on changes in the API or language specifications (there are other good articles).


I. Rough history

--In September 2017, Oracle announced a change in the Java release model, and at the same time announced that it would "publish paid features of the Oracle JDK in OpenJDK." That is, ** Java is now open (not paid). ** ** --Clients who have previously received support under a paid contract will continue to receive paid support. Only in this case will the JDK be offered as an "Oracle JDK" rather than an "Open" and will be charged for use in a production environment (which is often misunderstood).

About the release cycle

――Feature releases are provided in March and September every year, and major versions are going up. Ex: Java9 => September 2017, Java10 => March 2018, Java11 => September 2018, ... --Not all feature releases are Oracle JDK LTS (Long Term Support) **. In Java9 or later, Java11 and Java17 are LTS targets. Other than that, it is non-LTS.

--For more information, see Oracle Java SE Support Roadmap.

image.png

"8 and beyond"

--Java 8 is in the position of "the last version before the release model change". Java 8 itself is also open and is subject to LTS in the Oracle JDK. --When moving from Java 8 to Java 9, modularization called Project Jigsaw was adopted, and there were relatively major changes in the design. ――In other words, there is a big gap in terms of release model and compatibility between "Java 8 or earlier and Java 9 or later". You should be aware of both sides (without confusion) when migrating.

Distribution differentiation

--By making it open source, multiple vendors can build and announce the JDK. Surrounding the source of OpenJDK, ** there are multiple distributions of each company like Linux **. image.png (Source: How to choose the best OpenJDK distribution) --As of 2020, the major distributions are:

--The OpenJDK distributions of each company may be released and supported by narrowing down the versions such as "latest only" and "Oracle LTS target only". --For example, as of January 2020, Oracle OpenJDK has released the latest 13 as GA (General-Availability Release). Other versions can be downloaded, but their use is not recommended. --Also as of January 2020, Amazon Corretto has released 8 and 11.

--A series of tests called the Technology Compatibility Kit (TCK) have been prepared by the OpenJDK community (contract with Oracle) to endorse the distribution. Distributions that pass TCK can be called "Java SE compatible" --Some distributions, such as AdoptOpenJDK, do not pass TCK but are relatively popular.

How should I choose?

――It is realistic to judge by the support status and the ecosystem surrounding each distribution. --For example, do you have a paid license / support like Zulu? ――For example, is the installer properly prepared and easy to use? --For example, is an official Docker image available?

――However, there are few noticeable differences at present, and it is difficult to choose. Features may come out from now on.

II. Building a local development environment in 2020

Since the situation is as described in ~~ I, there is no fixed best, and it tends to become obsolete soon. ~~

=> SDKMAN! is the current best practice. (Added on 2020.1.10)

Here, we emphasize "installation is completed only on the command line" and "make it possible to switch between multiple versions", and the following two patterns of construction procedures are illustrated:

--Pattern 1: SDKMAN! (Recommended) --Pattern 2: Homebrew & jEnv

Pattern 1: Installation by SDKMAN!

https://sdkman.io/

SDKMAN! Is the predecessor of GVM, Groovy's multi-version control tool. It manages multiple versions of a wide variety of tools, centered on the JVM language and its build tools.

See the official for the installation of SDKMAN! After installation, Java installation is completed with the following command:

sdk install java      

The distribution installed at this time is 11 of Adopt Open JDK as of January 2020.

For other distributions, you can freely check and switch with the three subcommands list, ʻinstall, and default`. Use the Identifier in the list to specify the version and distribution.

sdk list java

================================================================================
Available Java Versions
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 AdoptOpenJDK  |     | 13.0.1.j9    | adpt    |            | 13.0.1.j9-adpt      
               |     | 13.0.1.hs    | adpt    |            | 13.0.1.hs-adpt      
               |     | 12.0.2.j9    | adpt    |            | 12.0.2.j9-adpt      
               |     | 12.0.2.hs    | adpt    |            | 12.0.2.hs-adpt      
               |     | 11.0.5.j9    | adpt    |            | 11.0.5.j9-adpt      
               | >>> | 11.0.5.hs    | adpt    | installed  | 11.0.5.hs-adpt      
               |     | 8.0.232.j9   | adpt    |            | 8.0.232.j9-adpt     
               |     | 8.0.232.hs   | adpt    |            | 8.0.232.hs-adpt     
 Amazon        |     | 11.0.5       | amzn    |            | 11.0.5-amzn         
               |     | 8.0.232      | amzn    |            | 8.0.232-amzn        
               |     | 8.0.202      | amzn    |            | 8.0.202-amzn        
 Azul Zulu     |     | 13.0.1       | zulu    |            | 13.0.1-zulu         
               |     | 12.0.2       | zulu    |            | 12.0.2-zulu  
       
...(Omission)...         

 SAP           |     | 12.0.2       | sapmchn |            | 12.0.2-sapmchn      
               |     | 11.0.4       | sapmchn |            | 11.0.4-sapmchn      
================================================================================

When installing the second and subsequent JDKs, you will be prompted if you want to make that distribution the default.

sdk install java 13.0.1-open # Oracle OpenJDK 13

Downloading: java 13.0.1-open

...(Omission)...

Installing: java 13.0.1-open
Done installing!

Do you want java 13.0.1-open to be set as default? (Y/n): Y

Setting java 13.0.1-open as default.

If you set it to the default, the Java version will switch at that point. No need to set a path. Try to check the startup of jshell.

jshell
|Welcome to JShell--Version 13.0.1
|For an overview, type:: /help intro
jshell>

jshell is a Java REPL added from Java 9. You may be familiar with it in other languages, but it is useful for a little operation check of the standard API. You can exit with / exit, so go back and try again.

sdk default java 11.0.5.hs-adpt

Default java version set to 11.0.5.hs-adpt
jshell
|Welcome to JShell--Version 11.0.5
|For an overview, type:: /help intro
jshell>

I was able to confirm that the version was switched.

Pattern 2: Installation by Homebrew & jEnv

Pattern 2: Installation by Homebrew & jEnv

  • Compared to SDKMAN !, it is more complicated and not recommended. It may be a reference for how the pass is passed on the back side *

** JDK installation with Homebrew **

https://brew.sh/index_ja

--Relatively recently (probably November 2019), ʻopenjdkwas added to Formulae. Therefore, it can be installed withbrew install openjdk`. --The distribution installed at this time is Oracle OpenJDK. --If you need to install Java 8 or earlier, or want to use another distribution, you'll currently be using Homebrew Cask (not included in this article). --Supported Formulae is quick to find here => https://formulae.brew.sh/formula/

If the installation is successful, you will notice a Caveats (warning). The following is the message when I tried it with Catalina + zsh.

==> Pouring openjdk-13.0.1+9.catalina.bottle.tar.gz
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

openjdk is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have openjdk first in your PATH run:
  echo 'export PATH="/usr/local/opt/openjdk/bin:$PATH"' >> ~/.zshrc

It's written lightly, but every paragraph is important. Depending on the environment, the details of the message and the actions to be taken may differ.

For the system Java wrappers to find this JDK, symlink it with...

It is not clear what "system Java wrappers" refers to, but it is necessary to create symbolic links in order to operate the java_home command described later.

openjdk is keg-only, which means it was not symlinked into /usr/local,...

It means that it is not symlinked under / usr / local, which means that typing java in the terminal at this point does not mean that the OpenJDK installed here will work immediately.

If you need to have openjdk first in your PATH run:...

In order for OpenJDK installed here to be searched first as a path, it is necessary to add the path when starting the shell.

However, this time it is a policy to manage multiple versions of JDK with another tool, so avoid writing the Java path directly in ~ / .zshrc.

With that in mind, just create the symbolic link recommended by the first message:

sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

This should allow the following commands to work:

java --version

openjdk 13.0.1 2019-10-15
OpenJDK Runtime Environment (build 13.0.1+9)
OpenJDK 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)
/usr/libexec/java_home

/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home

** Register with jEnv **

http://www.jenv.be/

A tool that makes it easier to manage multiple versions of the JDK, such as pyenv. The installation procedure will be officially handed over. After running brew install, you need to pass the path.

For example, with pyEnv, you can install Python with commands such as pyenv install 3.5.0. However, as you can see from the operations so far, jEnv itself does not have the function to download the JDK. The jenv add command requires" the full path to JAVA_HOME of the downloaded JDK" as an argument. This path can be referenced with the java_home command mentioned above.

/usr/libexec/java_home

/Library/Java/JavaVirtualMachines/openjdk.jdk/Contents/Home

Then you can use this to add the JDK to jEnv:

jenv add `/usr/libexec/java_home`

openjdk64-13.0.1 added
13.0.1 added
13.0 added

** Install multiple versions **

From the above state, for example, when installing Oracle OpenJDK 11 additionally, the procedure is as follows:

# 1.Install the JDK
brew install openjdk@11

# 2.Create a symlink under JavaVirtualMachines
# (Copy and paste the command that appears at the prompt during brew install)
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

# 3.Add to jEnv management
jenv add `/usr/libexec/java_home -v 11`

Check that jEnv can manage multiple versions and check the startup of jshell.

jenv versions

* system
  11.0
  11.0.5
  13.0
  13.0.1
  openjdk64-11.0.5
  openjdk64-13.0.1

Set the version to 13.

jenv global 13.0 

jenv versions

  system
  11.0
  11.0.5
* 13.0
  13.0.1
  openjdk64-11.0.5
  openjdk64-13.0.1
jshell
|Welcome to JShell--Version 13.0.1
|For an overview, type:: /help intro
jshell>

Then switch versions and try the same.

jenv global 11.0

jenv versions

  system
* 11.0
  11.0.5
  13.0
  13.0.1
  openjdk64-11.0.5
  openjdk64-13.0.1
jshell
|Welcome to JShell--Version 11.0.5
|For an overview, type:: /help intro

I was able to confirm that the version was switched.

If you do so far, you can say that it is a local development environment that can handle the addition of distributions and versions to some extent.

III. Sources and reference URLs

Due to the background described above, the information that developers should refer to depends on the distribution selected.

It would be nice to find a page that gives you a cross-cutting view of the current situation, but for now it's a good idea to first refer to the official Oracle roadmap, which leads the development of OpenJDK.

Oracle Java SE Support Roadmap https://www.oracle.com/technetwork/jp/java/eol-135779-ja.html

Vendors, such as Red Hat, may also publish their distribution lifecycles and policies.

OpenJDK Life Cycle and Support Policy https://access.redhat.com/articles/1299013

Other reference URL

(This article is mostly excerpts and summaries from the following articles, so if you want to know more, please!)

About the new release model and license offer of the JDK https://www.oracle.com/technetwork/jp/articles/java/ja-topics/jdk-release-model-4487660-ja.html

Project Jigsaw https://openjdk.java.net/projects/jigsaw/

What to choose for the future JDK? How to choose (v1.2) https://www.slideshare.net/TakahiroYamada3/how-to-choose-jdk-20191101 (Added 2020-03-09. Thank you @yamadamn)

How to choose the best OpenJDK distribution https://www.slideshare.net/TakahiroYamada3/how-to-choose-the-best-openjdk-distribution-201905

Summary to explain as easily as possible to those who misunderstand in "Java paid" https://togetter.com/li/1343743

OpenJDK - Wikipedia https://ja.wikipedia.org/wiki/OpenJDK

Oracle JDK vs. OpenJDK builds comparison https://devexperts.com/blog/oracle-jdk-vs-openjdk-builds-comparison/

Recommended Posts

What happened in "Java 8 to Java 11" and how to build an environment
How to install the language used in Ubuntu and how to build the environment
How to change Java version and execute in an environment where Java cannot be installed freely
How to solve an Expression Problem in Java
[Rails] How to build an environment with Docker
How to build an executable jar in Maven
What to do and how to install when an error occurs in DXRuby 1.4.7
How to create a Java environment in just 3 seconds
How to convert A to a and a to A using AND and OR in Java
How to build Java development environment with VS Code
How to learn JAVA in 7 days
How to call and use API in Java (Spring Boot)
How to use classes in Java?
How to name variables in Java
How to develop and register a Sota app in Java
Differences in how to handle strings between Java and Perl
How to concatenate strings in java
[Java] How to use static modifiers (What are static final and static import)
How to build an Apache Flink application from scratch in 5 minutes
How to encrypt and decrypt with RSA public key in Java
How to get the length of an audio file in java
How to implement date calculation in Java
How to implement Kalman filter in Java
Multilingual Locale in Java How to use Locale
How to reflect seeds.rb in production environment
How to do base conversion in Java
[Java] How to output and write files!
How to build SquashTM and how to support Japanese
How to implement coding conventions in Java
How to embed Janus Graph in Java
How to get the date in java
How to use environment variables in RubyOnRails
Java to C and C to Java in Android Studio
How to build Rails 6 environment with Docker
How to test a private method in Java and partially mock that method
How to build an environment for any version of Ruby using rbenv
How to make an app with a plugin mechanism [C # and Java]
How to create your own annotation in Java and get the value
Try to build Java8 environment on Amazon Linux2
Resolved the error that occurred when trying to use Spark in an environment where Java 8 and Java 11 coexist.
[Java] How to use FileReader class and BufferedReader class
I want to send an email in Java.
[Java] How to get and output standard input
How to display a web page in Java
How to install Titan2D (v4.2.0) in virtual environment
How to get Class from Element in Java
Build an E2E test environment with Selenium (Java)
How to hide null fields in response in Java
Rails6.0 ~ How to create an eco-friendly development environment
How to get and study java SE8 Gold
How to build API with GraphQL and Rails
[Java] How to substitute Model Mapper in Jackson
How to build parquet-tools and merge Parquet files
How to build a Pytorch environment on Ubuntu
How to build the simplest blockchain in Ruby
How to write Java String # getBytes in Kotlin?
[Rails] How to use PostgreSQL in Vagrant environment
How to access Java Private methods and fields
[Java] How to use Calendar class and Date class
How to concatenate strings separated by commas using StringJoiner even in java7 environment
How to send custom metrics and events to datadog with laravel in docker-compose environment