[JAVA] How to get JDK 11 on your mac in a comfortable way

Addendum 2018-10-16 As soon as I wrote it, this article seems to be unnecessary. When Amazon Corretto announced the other day comes out! If you look at the download page for Corretto 8 which is currently in preview, the mac version is available as a pkg file! This is a great possibility of pkg even in Corretta 11! There is a great possibility that the installer will do various things and you will be comfortable from the beginning! It may be. Corretto 11 will be available after thorough testing until April next year, so if you can't wait until then, please try it.

Target audience

--In the old days, those who have used the JDK of Oracle after Apple --For those who want to use it without setting jshell or troublesome paths

What is comfortable

--Happy that the path is in the tools of the JDK.

Steps to be comfortable

Just install it once with the dmg package of OracleJDK 11, uninstall it, and then install OpenJDK 11 [^ 1]. If the number of tools increases after 12 in the future, it is good to follow the same procedure with the upgraded version.

1. Download and install the dmg version of the Oracle JDK

-From Java SE Development Kit 11 Downloads for mac Download the JDK with the extension .dmg. --Mount the dmg file, execute the pkg file inside, and complete the next on the installer screen.

2. Uninstall immediately

Do exactly what is in here

2.1. Execute the following from the terminal

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin 
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane 
sudo rm -fr ~/Library/Application\ Support/Oracle/Java

2.2. Removed JDK [^ 2]

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk

3. Install OpenJDK

--Download OpenJDK 11 from the highly recommended AdoptOpenJDK. I like the choice of Hotspot or OpenJ9 [^ 3]. --Double-click to expand from Finder --In the terminal, move the extracted folder [^ 2] to the location where the Oracle JDK was.

sudo mv ~/Downloads/jdk-11.0.1+13 /Library/Java/JavaVirtualMachines/

--If there are multiple JDKs in .bashrc or .zshrc, java_home will return the latest, so modify it as follows.

export JAVA_HOME=$(/usr/libexec/java_home)

It seems that the pkg installer of Oracle JDK installed first creates a link such as / usr / bin / jshell, so it is better than simply installing OpenJDK.

By the way, it seems that the latest JDK is automatically selected for the desktop regardless of the terminal settings. I was a little worried that when I installed eclipse-201809 with Oracle Java, all versions in / Library / Java / JavaVirtualMachines / were displayed in Installed JRE, but for some reason I changed to OpenJDK, only jdk-9. It disappeared and I had to manually insert others. I wonder if there was something around ~ / Library / Application \ Support / Oracle / Java. I don't know if I erased it already.

[^ 1]: To tell the truth, ** "Please prepare an OpenJDK package installer that automatically sets up like Oracle JDK" **. [^ 2]: If the version is up, please read and execute as appropriate. [^ 3]: I chose Hotspot because I imagined that there would be little discrepancy with Oracle JDK, but if you want to use eclipse, OpenJ9 may be better. I don't know.

Recommended Posts

How to get JDK 11 on your mac in a comfortable way
As of April 2018 How to get Java 8 on Mac
How to install JDK8-10 (Mac)
How to get inside a container running on AWS Fargate
How to display a graph in Ruby on Rails (LazyHighChart)
How to switch Java in the OpenJDK era on Mac
How to get parameters in Spark
[Rails] A simple way to implement a self-introduction function in your profile
How to switch Java version with direnv in terminal on Mac
How to check Java installed on Mac
How to get date data in Ruby
How to insert a video in Rails
How to install Eclipse (Photon) on Mac
How to switch Java versions on Mac
Build a JMeter environment on your Mac
How to create a query using variables in GraphQL [Using Ruby on Rails]
How to get the current date as a string in yyyyMMdd format
How to get the absolute path of a directory running in Java
How to create your own annotation in Java and get the value
How to get keycloak credentials in interceptor class
How to deploy a container on AWS Lambda
How to get a heapdump from a Docker container
How to display a web page in Java
How to get Class from Element in Java
How to run a djUnit task in Ant
How to add a classpath in Spring Boot
How to create a theme in Liferay 7 / DXP
How to implement a like feature in Rails
How to easily create a pull-down in Rails
[Ruby on Rails] How to install Bootstrap in Rails
How to build a Pytorch environment on Ubuntu
Notes on how to write comments in English
How to automatically generate a constructor in Eclipse
How to get the ID of a user authenticated with Firebase in Swift
[Spring Boot] How to get properties dynamically from a string contained in a URL
[Rails] How to get rid of flash messages in a certain amount of time
How to clear all data in a particular table
How to create a Java environment in just 3 seconds
How to implement a like feature in Ajax in Rails
[Ruby on Rails] How to write enum in Japanese
How to get information about associated tables in many-to-many tables
How to create a Spring Boot project in IntelliJ
How to make JavaScript work on a specific page
How to create a data URI (base64) in Java
[Java] How to get a request by HTTP communication
How to display a browser preview in VS Code
[How to insert a video in haml with Rails]
How to check the WEB application created in the PC development environment on your smartphone
How to write a date comparison search in Rails
How to store Rakuten API data in a table
How to mock a super method call in PowerMock
How to convert A to a and a to A using AND and OR in Java
How to convert a file to a byte array in Java
[Rails 6] How to set a background image in Rails [CSS]
[Rails] How to load JavaScript in a specific view
Fargate to get a rough idea in relation to EC2
How to write a core mod in Minecraft Forge 1.15.2
How to get started with creating a Rails app
[Ruby/Rails] How to generate a password in a regular expression
Notes on how to use regular expressions in Java
How to get jdk etc from oracle with cli