How to install openjdk with brew


(freshghost) #1

now,how to install openjdk with brew .


(Mike McQuaid) #2

brew cask install java


(Stefan Crain) #3

brew cask install java does not install openjdk version of java but oracle java.

$ brew cask info java
java: 9,181
https://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html
Not installed
From: https://github.com/caskroom/homebrew-cask/blob/master/Casks/java.rb
==> Name
Java Standard Edition Development Kit
==> Artifacts
JDK 9.pkg (Pkg)
==> Caveats
This Cask makes minor modifications to the JRE to prevent issues with
packaged applications, as discussed here:

  https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361

If your Java application still asks for JRE installation, you might need
to reboot or logout/login.

Installing this Cask means you have AGREED to the Oracle Binary Code
License Agreement for Java SE at

  https://www.oracle.com/technetwork/java/javase/terms/license/index.html

Does anyone have a further lead on this?


(Joshua McKinney) #4

There is no openjdk Formula or Cask. A quick browse of the openjdk website didn’t particularly promise any easy obvious ways to install for macOs.

Your best bet for this is to work with the upstream developers on working out what’s built / available for macOS and help them to create a formula / cask (depending on whether it’s delivered predominantly as source / CLI only vs binary / CLI + GUI stuff like JavaSE).


(George Adams) #5

I would recommend checking out https://github.com/AdoptOpenJDK/homebrew-openjdk where you can go and grab prebuilt openjdk binaries for macOS!

It’s just a case of using:

brew tap AdoptOpenJDK/openjdk
brew install <version>

Where version is:

  • adoptopenjdk-openjdk8
  • adoptopenjdk-openjdk9
  • adoptopenjdk-openjdk10

(Luke Dutton) #6

Thank you so much for this!
Where is the openjdk placed when you install it this way?
When you install the oracle jdk, it is placed in the java virtual machines folder.


(Jeno Dk) #7

@Jolley71717

 ~ $ java -version
openjdk version "1.8.0-adoptopenjdk"
OpenJDK Runtime Environment (build 1.8.0-adoptopenjdk-jenkins_2018_05_19_02_01-b00)
OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)
λ ~ $ ls -l `which java`
lrwxr-xr-x  1 jeno  admin    53B Oct  5 10:37 /usr/local/bin/java@ -> ../Cellar/adoptopenjdk-openjdk8/jdk8u172-b11/bin/java

Allthough I do have something strange, my $JAVA_HOME still points to a previously installed JDK:

λ ~ $ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home

Anyone knows a nice way to switch in between openJDK’s (can be different versions as well) and oracle JDK’s?
For just oracle JDK’s I was planning to use https://stackoverflow.com/a/47699905 , would this also work for openJDK’s?


(Jeno Dk) #8

My $JAVA_HOME I just set manually or let jenv do it

Followed this:
https://gist.githubusercontent.com/chaines27/7f9a91237e79e6b4b28899b96d74986f/raw/96348a1014aaf4b6153895b2010324d3eb4b14f5/homebrew-openjdk-configuration

Open github issue:


(George Adams) #9

For people having issues witht the AdoptOpenJDK brew taps ands JAVA_HOME issues. Please check out the brand new brew cask. Simply run brew cask install adoptopenjdk. This currently only works for OpenJDK11 but we will be converting our previous versions over to casks soon!


#10

As of 9 Oct 2018 I see openJDK when I search for java.

brew cask info java
java: 11,28
https://jdk.java.net/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/master/Casks/java.rb
==> Name
OpenJDK
==> Artifacts

Or am I reading that wrong?


(Sean Molenaar) #11

You’re reading it correctly but openjdk is now the “official” implementation unless you paid for it. https://blogs.oracle.com/java-platform-group/oracle-jdk-releases-for-java-11-and-later


#12

Is there a difference between the openjdk provided by the cask java and the cask adoptopenjdk?


(Sean Molenaar) #13

AdoptJDK is https://adoptopenjdk.net/
OpenJDK is https://jdk.java.net/


#14

But are they the same source or are they competing implementations of the JDK? I haven’t followed the java world very closely so I’m not sure if there was a fork or something.


(Sean Molenaar) #15

Should be the same source but packaged differently. You can check the adoptopenjdk github to see if they do anything special to the build