Search code examples
javahomebrewjava-12

How do I install Java 12 on Mac OSX now that Java 13 is out?


I cannot find Java 12 to install anymore, just Java 13. But Gradle does not support Java 13 yet, so I need to use 12 as an alternative for now. When I look in Homebrew using brew search java I find all sort of javas: Java 11, Java 6 (!) and Java, which used to be Java 12 but is now Java 13.

Any idea how I can get Java 12?


Solution

  • Solution 1

    You can get Java 12 from the AdoptOpenJDK Homebrew tap. (a tap is a formula repository) And the AdoptOpenJDK team maintains different versions of JDK in this repo.

    brew tap AdoptOpenJDK/openjdk
    brew install --cask adoptopenjdk12
    

    enter image description here

    Solution 2

    java is a formula defined in the repo Homebrew-cask. You can search and find the history file java.rb where Java 12 was defined within, and install Java 12 with the URL to that specific history file.

    The following command installs vanilla OpenJDK (not the AdoptOpenJDK) 12.0.2.

    brew cask install https://raw.githubusercontent.com/Homebrew/homebrew-cask/26203ad42b40c4bc3baa2f6cfa8469f1245b7fbc/Casks/java.rb