Manually Install OpenJDK in OSX Mojave

Mindwatering Incorporated

Author: Tripp W Black

Created: 01/27/2020 at 03:14 PM

 

Category:
OS X Tips & Hints
General Mac Tips

Task:
Replace the Oracle-branded Java with OpenJDK version (still Oracle maintained).


Notes:
- The later versions of Apple MacOS uses the /usr/libexec/java_home program to locate Java versions and do that pop-up to install the Oracle one after you de-installed the Oracle version.
To check, open a new Terminal window, and check:
$ /usr/libexec/java_home -V
After we are done this task, this command will output our new virtual machines.
Matching Java Virtual Machines (1):
13.0.2, x86_64: "OpenJDK 13.0.2" /Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home
- With MacOS, we can have more than one Java (JVM) installed. We just have to use the correct directory structure, as the directory path above.
- Specifically, we will be adding the Java program for "all users" by adding the Java/JVM to the main /Library/ folder structure instead of the current user ~/Library/ folder structure.
- At this writing, the OpenJDK version does not include the javaws and JLNP. They are installed separately (Hint: IcedTea project at jdk.java.net).


Prerequisite Steps:
If this Mac has never had a Java JVM installed, all the folder structure needs to be added.
Using the same terminal window, perform the following, as needed:
$ sudo su
< enter password>
# cd /Library/
Check if Java folder exists.
# ls Java
If no result, run # mkdir Java to create the folder.
# cd Java
# ls JavaVirtualMachines
If no result, run # mkdir JavaVirtualMachines to create the folder.
Our Java JVM will be added inside this folder. Exit root user.
# exit
Leave the Terminal window open or minimized.


Steps to Download and Install:
1. Using your web browser, visit the OpenJDK Downloads page at Java.Net:
https://jdk.java.net

Beside the Ready for use label, choose the current version:
e.g. JDK 13

2. On the JDK General-Availability Release page for this version of Java (e.g. JDK 13.0.2), under the Build "x" header, click the tar.gz macOS/x64 link.
e.g. openjdk-13.0.2_osx-x64_bin.tar.gz

3. Once downloaded, open the Downloads folder, locate the tar.gz file, and double-click to expand/decompress the archive.

The result will be a folder with the same version:
e.g. jdk-13.0.2.jdk

4. Leaving the Downloads Finder window open, open another Finder window via the Finder menu Go --> Go to folder. In the pop-up, enter /Library/Java/JavaVirtualMachines/ and click Go.
Note:
On one of our machines that never had a JVM (Java) installed, we didn't have a Java folder. We had to create the folder inside the Library folder.
If the JavaVirtualMachines folder does not exist create it.

5. Drag-drop the expanded folder, e.g. jdk-13.0.2.jdk from the Downloads Finder window into the JavaVirtualMachines Finder window.
Authenticate as prompted.
The JVM is now installed.


Validation:
Return to the Terminal window still open, enter the java_home command again, this time, we should see that the JVM is installed.
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (1):
13.0.2, x86_64: "OpenJDK 13.0.2" /Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home

The Java JVM is installed and ready.


IcedTea-Web
If installing a Mac, or Windows 32 bit installation, the iced-tea project is not an optional install of the main JDK MSI or Pkg.
If doing a manual install/add-on of the iced-tea folders and binaries, for MS Windows it looks like this:
- copy the iced-tea/bin/javaws.exe file to the jdk-8xyz/bin folder
- copy the iced-tea/bin/itweb-settings.exe file to the jdk-8xyz/bin folder (if not exists)
- copy the iced-tea/bin/itw-modularjdk.args file to the jdk-8xyz/bin folder (if not exists)
- copy the iced-tea/bin/policyeditor.exe file to the jdk-8xyz/bin folder
- copy all 4 icedtea/share jar files to the jdk-8xyz/share/icedtea-web folder
- copy the icedtea/share/pixmaps/ to the jdk-8xyz/share/pixmaps folder if ico doesn't already exist there.
- copy the icedtea/share/doc/icedtea-web/ to the jdk-8xyz/share/doc/icedtea-web/ folder
- copy the icedtea/icedtea-web-docs/ folder to the jdk-8xyz/icedtea-web-docs/ folder.

For the Mac, the folder for the main JDK is different:
Instead of jdk-8xyz/bin, the folder structure is jdk-8xyz/Contents/Home/bin. So basically just stick /Contents/Home/ in between the paths above.





previous page