How to change from Oracle Java 8 to Adopt Open JDK 9

Introduction

I think that the Java community is busy with the changes in the release cycle of Oracle and the license support form these days. Paid support is difficult in terms of cost, and there are many cases where the release cycle is difficult as short as half a year, so AdoptOpenJDK seems to be one of the leading candidates as an option. I tried to explore and introduce it, so I will summarize it here.

** Supplement. At first, I intended to change the article up to AdoptOpenJDK 11. I was writing this article while upgrading the application version, but on the way I found out that the core library does not support Java 9 or later. I will try it on another occasion to complete the article, but until then I can only write up to AdoptOpenJDK Java 9. ** **

Prior information

from Java:Oracle Java 8 to java:AdoptOpenJDK9 OS:Windows 64bit、Linux(CentOS)64bit

download

Download from AdoptOpenJDK. The latest release page may only be built for a single platform, so I think it's better to select it individually from the archive page below. https://adoptopenjdk.net/archive.html 2018-11-09_18h52_55.png

  1. Choose a Version This time we will raise Java 8 → 9, so get each of 8 and 9 (although it is the same version, check Oracle Java 8 → AdoptOpenJDK9).
  2. Choose a JVM (Java Virtual Machine Choice) Select the JVM implementation you want to use. I think it will be a criterion to use Hotspot if you are using so-called Oracle Java, and OpenJ9 if you are using IBM Java. I can't find much of this credible information, and while it's a sensory story, I get the impression that the JVM changes are scary. Although it is a personal blog, there was a person who was measuring the benchmark, so I will just introduce it. Looking at this, Hotspot was advantageous in terms of CPU speed, and OpenJ9 was advantageous in terms of memory saving. https://royvanrijn.com/blog/2018/05/openj9-jvm-shootout/ https://royvanrijn.com/blog/2018/05/openj9-hotsport-specjvm2008/ However, as written in the link, if you make a proper judgment, you should not take this result and actually measure it yourself in the target environment.

Installation

Installation method

It doesn't come with an installer like Oracle java. The official installation method is briefly explained below, but it's a little subtle (I don't use JAVA_HOME), so I'll change it a little. https://adoptopenjdk.net/installation.html?variant=openjdk8&jvmVariant=hotspot

  1. Download As mentioned above.
  2. (Optional) Checksum confirmation Since the file size is quite large, if you are worried about corruption, check the checksum value.
  3. Archive expansion First, unzip it according to the environment where you use .zip or .tar.gz. Place them anywhere. ex) Windows:「C:/Program Files/Java/jdk8u192-b12」 Linux:「/user/java/jdk8u192-b12」
  4. Pass through PATH I don't want to mess with PATH so much, so let's go through an environment variable called JAVA_HOME (I think it is customary). You can minimize the effect by registering only JAVA_HOME in the PATH and rewriting only JAVA_HOME when changing the java version. And since I don't want to play with environment variables too much, the destination pointed to by JAVA_HOME is also a directory of symbolic links (it seems that there are many latest and default). PATH =% JAVA_HOME% \ bin; (Omitted) JAVA_HOME="C:\Program Files\Java\latest" image.png In the subsequent installation, the procedure here is to change only the direction of the symbolic link. If something doesn't work, it's okay to reverse this direction.
  5. Version check Type java -version. You should see the word AdoptOpenJdk in that version. image.png

Java8 First from Java 8. As a premise, the original Java is 8, so it should work without problems.

-(Supplement) UNIX-like only: About securerandom.source

Although it is limited to UNIX environment, it is easy to forget to change the setting value of securerandom.source, so note it here. The initial setting for random number generation is "/ dev / random", but it doesn't need to be so strict, and the delay due to the exhaustion of random numbers is more problematic, so I changed the setting to "/ dev / urandom". I think there are many environments. In such an environment, it is necessary to remember to change the settings after installing Adopt Open JDK as well as the existing settings. Don't forget to change the settings for ** each version **. Click here for how to change settings, etc .: http://otndnld.oracle.co.jp/document/products/E13153_01/wlcp/wlss40/configwlss/jvmrand.html

Java9 Onimon causes a number of problems due to configuration changes using the module function "Project Jigsaw". For reference, I stumbled a little. The [Java 9 Migration Guide] issued by Oracle (https://docs.oracle.com/javase/jp/9/migrate/toc.htm#JSMIG-GUID-7744EF96-5899-4FB2-B34E-86D49B2E89B6) is a must read.

--Gradle doesn't work

Older Gradle will give the error "Could not determine java version from". https://qiita.com/Kaoru_Yamamoto/items/dcb3815795d6e752cff3

--Illegal Access To Internal APIs warning occurs

Some of Java's internal APIs that were not supposed to be used from the outside could be used up to Java 8, but they are now restricted. Limits mean that they are no longer available or you get a WARN warning. [Countermeasure ①] (Fundamental support) Rewrite the source to the alternative API. [Countermeasure ②] (Temporary support) Add Java startup option "--add-exports (corresponding API)". [Countermeasure ③] (Temporary support) Add Java startup option "--add-opens (corresponding API)". This is an option if you are operating the API with reflection.

The provisional support is a transitional measure and may not be available in future versions, so it is necessary to take fundamental measures as soon as possible.

https://blog.codefx.org/java/java-9-migration-guide/#Illegal-Access-To-Internal-APIs

Recommended Posts

How to change from Oracle Java 8 to Adopt Open JDK 9
[Java] How to switch from open jdk to oracle jdk
How to get jdk etc from oracle with cli
How to pass Oracle Java Silver
How to change from HTML to Haml
[Talend] Switching from Oracle JDK to OpenJDK
Java: How to send values from Servlet to Servlet
How to download Oracle JDK 8 rpm with curl
How to get Class from Element in Java
How to Install Oracle JDK 1.8 in Ubuntu 18.04 LTS?
Changes from Java 8 to Java 11
Sum from Java_1 to 100
From Java to Ruby !!
[Android Studio] How to change TextView to any font [Java]
How to jump from Eclipse Java to a SQL file
How to write Scala from the perspective of Java
How to use Oracle JDK 9 EA with Travis CI
[Java] How to extract the file name from the path
[Java] How to erase a specific character from a character string
[Beginner] How to use devise Change settings from introduction
[Java] How to use Map
How to lower java version
Migration from Cobol to JAVA
[Java] How to use Map
How to uninstall Java 8 (Mac)
Java --How to make JTable
How to use java Optional
New features from Java7 to Java8
How to minimize Java images
How to write java comments
[Java] How to use Optional ②
Connect from Java to PostgreSQL
[Java] How to use removeAll ()
[Java] How to use string.format
How to use Java Map
How to set Java constants
How to use Java variables
How to convert Java radix
[Java] How to implement multithreading
Change from SQLite3 to PostgreSQL
[Java] How to use Optional ①
How to install JDK8-10 (Mac)
From Ineffective Java to Effective Java
How to migrate from JUnit4 to JUnit5
How to initialize Java array
[Java] How to convert a character string from String type to byte type
How to store a string from ArrayList to String in Java (Personal)
How to write and notes when migrating from VB to JAVA
How to dynamically switch JDK when building Java in Gradle
How to study Java Silver SE 8
How to use Java HttpClient (Get)
How to push from Tarminal to GitHub
Studying Java # 6 (How to write blocks)
[Java] How to update Java on Windows
How to make a Java container
How to disassemble Java class files
How to use Java HttpClient (Post)
Install Java Open JDK 8 on CentOS 7
How to learn JAVA in 7 days
Android: How to deal with "Could not determine java version from '10 .0.1'"
How to change kube-proxy to ipvs mode.