Skip to content

Instantly share code, notes, and snippets.

@chaines27
Last active June 14, 2022 08:29
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save chaines27/7f9a91237e79e6b4b28899b96d74986f to your computer and use it in GitHub Desktop.
Save chaines27/7f9a91237e79e6b4b28899b96d74986f to your computer and use it in GitHub Desktop.
Configuration for homebrew-openjdk for macOS to see it as an installed JVM
OpenJDK 1.8
1. Follow the instructions from https://github.com/AdoptOpenJDK/homebrew-openjdk to tap and install jdk8.
2. Run the following command to create the necessary directories
sudo mkdir /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk
sudo mkdir /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents
sudo mkdir /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents/MacOS
3. Run the following commands to link to the existing homebrew-openjdk install
sudo ln -s /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents/Home /usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11
sudo ln -s /usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11/jre/lib/jli/libjli.dylib /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents/MacOS/libjli.dylib
4. Copy the contents of https://gist.github.com/chaines27/32810cdfddefeeb5965e2969eb709fb5 to /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents/Info.plist
5. Verify that macOS sees the openjdk by running
/usr/libexec/java_home -V
You should see something like this:
Matching Java Virtual Machines (1):
1.8.0_172, x86_64: "OpenJDK 1.8.0" /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents/Home
OpenJDK 10.0
1. Follow the instructions from https://github.com/AdoptOpenJDK/homebrew-openjdk to tap and install jdk10.
2. Run the following command to create the necessary directories
sudo mkdir /Library/Java/JavaVirtualMachines/openjdk-10.0.1+10.jdk
sudo mkdir /Library/Java/JavaVirtualMachines/openjdk-10.0.1+10.jdk/Contents
sudo mkdir /Library/Java/JavaVirtualMachines/openjdk-10.0.1+10.jdk/Contents/MacOS
3. Run the following commands to link to the existing homebrew-openjdk install
sudo ln -s /Library/Java/JavaVirtualMachines/openjdk-10.0.1+10.jdk/Contents/Home /usr/local/Cellar/adoptopenjdk-openjdk10/jdk-10.0.1+10
sudo ln -s /usr/local/Cellar/adoptopenjdk-openjdk10/jdk-10.0.1+10/lib/jli/libjli.dylib /Library/Java/JavaVirtualMachines/openjdk-10.0.1+10.jdk/Contents/MacOS/libjli.dylib
6. Copy the contents of https://gist.github.com/chaines27/14b194becf92f61885857051cfc25518 to /Library/Java/JavaVirtualMachines/openjdk-10.0.1+10.jdk/Contents/Info.plist
7. Verify that macOS sees the openjdk by running
/usr/libexec/java_home -V
You should see something like this:
Matching Java Virtual Machines (2):
10.0.1, x86_64: "OpenJDK 10.0.1" /Library/Java/JavaVirtualMachines/openjdk-10.0.1+10.jdk/Contents/Home
1.8.0_172, x86_64: "OpenJDK 1.8.0" /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/openjdk-10.0.1+10.jdk/Contents/Home
@rsflaherty
Copy link

I think line 11 above should be flipped.
So change
sudo ln -s /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents/Home /usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11
to
sudo ln -s /usr/local/Cellar/adoptopenjdk-openjdk8/jdk8u172-b11 /Library/Java/JavaVirtualMachines/openjdk-1.8.0_172.jdk/Contents/Home

@rsflaherty
Copy link

Same for line 37 re: version 10

@yuriy-eremin
Copy link

I fixed symlink creation for jdk home regarding @rsflaherty comments.
Please merge gist from my fork https://gist.github.com/yuriy-eremin/df9bd4b2b2dc5e9ad8f1dc44a308692e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment