How to upgrade to latest version of java JDK using homebrew cask? - java

I have been following these instructions to install the latest java jdk:
www.lonecpluspluscoder.com/2017/04/27/installing-java-8-jdk-os-x-using-homebrew/
brew cask install java
This works great, but when a new version comes out, how do I make sure I can upgrade to that version and ensure that old versions of the jdk are not sitting around on my system?

Warning: Calling brew cask reinstall is deprecated! Use brew reinstall instead
brew reinstall java

brew cask reinstall java
This command will uninstall old version of jdk and install the latest version

By default, Homebrew does not uninstall old versions of a formula, so over time you will accumulate old versions.
The cleanup - brew cleanup command will remove outdated installed package versions.

To upgrade the sub-version of java i.e from 11.0.8,10 to 11.0.9.1,1, use the following command.
brew upgrade --cask adoptopenjdk11

Related

sdkman on OSX can neither install nor uninstall Java 1.8

Running OSX 10.15.7, sdkman 5.9.1+575.
sdkman seems to have gotten into a bad state where it thinks Java 1.8 both is and is not installed.
$ sdk uninstall java 1.8.0 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/
java 1.8.0 is not installed.
$ sdk install java 1.8.0 /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/
java 1.8.0 is already installed.
$ ls /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk
ls: /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk: No such file or directory
Java 1.8 was installed through sdkman and working fine, then I ran a blanket brew upgrade and I think it tried to upgrade my Java version. I am not 100% that this is the cause - it was about a week ago and that terminal session is long gone, and ~/Library/Logs/Homebrew/openjdk is empty.
How can I get sdkman unstuck, or how can I uncover more information about what's wrong?
I cross-posted this in the sdkman slack channel and got a solution. Posting here for posterity.
My mistake was using SDKMAN to coordinate the brew installed version of Java. Apparently this is very cumbersome, and will break every single time that brew releases a new version of that JDK.
Steps to resolve:
$ unlink ~/.sdkman/candidates/java/1.8.0
$ sdk install java 8.0.282.j9-adpt
This disconnects sdkman from the brew version of Java, and adds a parallel installation of Java 8.

How can I install openjdk 8 and sbt on mac and have openjdk 8 (not 13) the default one?

Installing java 8 and sbt with brew and/or brew cask is clearly possible,
The problem I am hitting is that brew installs java 13 as sbt dependency,
And I do not know a general way to go back to java 8 as default, since there are so many ways potentially to opt between java version some of which i am aware include PATH, JAVA_HOME, ln -s, java_exec selector.
Another problem potentially is that brew install sbt installs brew install java which is 13,
But java 8 I install it via brew cask.
The TL is saying that Java 13 or 14 might be causing some issues e.g. tests fails, should I push for latest versions of OpenJdk, Scala, SBT, etc?
Indeed, SDK Man is an option.
It actually works with brew also but there need to be just a few manual steps: here they are:
Installing sbt, java8, jenv & configure the shell
We used brew to install sbt (which in its turn installs java 13), and brew cask to install openjdk java 8, like this:
brew install sbt
brew tap AdoptOpenJDK/openjdk
brew cask install adoptjava8
We will use jenv to manage the java versions, with the information from https://github.com/Homebrew/homebrew-core/issues/31390
Basically the next steps are:
brew install jenv
jenv init -
echo 'eval "$(jenv init -)"' >> ~/.bash_profile
echo 'eval "$(jenv init -)"' >> ~/.zprofile
jenv add <path-to-java8-Home-Dir>
Then restart your terminal and you should now be able to run sbt
Where at time of writing <path-to-java8-Home-Dir> is /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
Have a look at a utility like Sdk Man.
It is multi-platform and allows you to set any desired JDK as a default one.
As well as changing it to another provider/version when it will be required.

Installing OpenJDK 8 (subversion 1.8.0.119) for Mac using Homebrew?

I want to install OpenJDK 8 version 1.8.0.119 on my Mac using Homebrew. What is the brew command to specify the version while installing?
I am able to install OpenJDK using the brew command brew cask install adoptopenjdk/openjdk/adoptopenjdk8, but the version installed (1.8.0.212) is later than the one I want.
The formulae in Homebrew core and the AdoptOpenJDK tap only support the latest versions of a given major release. If you need to install a particular minor version or point release, you will need to create your own custom formula in a custom tap you maintain.
Start with one of the existing formulae for the major release you want. Copy it to your custom formula, and include the version in your new formula name. Edit the formula to point at the download URL for the particular version you want, and fix up the sha256 checksum value.
From AdoptOpenJDK/homebrew-openjdk github, we can see it only support install fixed version, for jdk8, it is 1.8.0.212.
The oldest version for jdk8 on AdoptOpenJDK website is 1.8.0.172.

Unable to install java8 with homebrew

Installing java8 with Homebrew seems to no longer be working. After running:
brew install caskroom/cask/java8
I get the following error:
Error: Cask 'java8' is unavailable: '/usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask/Casks/java8.rb' does not exist.
Simply doing:
brew cask install java8
Errors out with:
Error: Cask 'java8' is unavailable: No Cask with this name exists.
This seems like a recent development because I remember installing it this way a few months ago. Any suggestions on how to properly install java8 on MacOS nowadays?
New command is now :
brew install --cask homebrew/cask-versions/adoptopenjdk8
This has already been answered as a github issue: https://github.com/Homebrew/homebrew-cask-versions/issues/7253
TLDR: the java8 artefact refers to the Oracle distribution, which has ceased being supported/available. If you really need java 1.8 instead of the latest versions you can take a look at AdoptOpenJDK/homebrew-openjdk.
The command is now brew install homebrew/cask-versions/adoptopenjdk8 --cask
brew install homebrew/cask-versions/adoptopenjdk8 --cask
In the latest changes of homebrew cask will have to be at the last.
AdoptOpenJDK has been deprecated, and transitioned to Eclipse Temurin from Adoptium. See this blog post:
https://blog.adoptopenjdk.net/2021/03/transition-to-eclipse-an-update/
To install Temurin Java 8, aka 1.8, with Homebrew, you can use:
brew tap homebrew/cask-versions
brew install --cask temurin8
If you already had AdoptOpenJDK installed using the commands in the other answers, you should uninstall it first, with:
brew uninstall --cask adoptopenjdk8
You can also download a .pkg for manual installation (the former link at AdoptOpenJDK now leads here):
https://adoptium.net/?variant=openjdk8
For Homebrew 2.7.0. the brew cask commands are disabled
The command is now changed to
brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
for new version use
brew install --cask adoptopenjdk/openjdk/adoptopenjdk8
Although cask remove the support for JAVA8, we can still install JAVA8 using brew.
It requires the manual download of JAVA8.dmg and add the java8.rb which could be used by cask.
Machine: MAC
OS: Mojave (10.14.6)
JAVA version: java 8u231
Step-1
Download dmg file from Oracle Site. You require oracle account to download the same
Step-2
Start the HTTP server from the folder where you downloaded the dmg file. For me it's ~/Downlaods and I use python to start HTTP server:
python -m SimpleHTTPServer 8000
Step-3
Create file java8.rb in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks (where java.rb exist) and add the following:
cask 'java8' do
version '8u231,b15:9eef341qase34d44fbaa21'
sha256 'f808d11b34fa9ee7b6326b5b6dd18544496e02c84b839d94e062bd4493df5d45'
url "http://localhost:8000/jdk-#{version.before_comma}-macosx-x64.dmg",
cookies: {
'oraclelicense' => 'accept-securebackup-cookie',
}
name 'Oracle Java 8 Standard Edition Development Kit'
homepage 'https://www.oracle.com/technetwork/java/javase/overview/index.html'
depends_on macos: '>= :yosemite'
pkg 'JDK 8 Update 231.pkg'
uninstall pkgutil: "com.oracle.jdk#{version.before_comma}",
delete: [
'/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin',
'/Library/PreferencePanes/JavaControlPanel.prefPane',
]
zap trash: [
'~/Library/Application Support/Oracle/Java',
'~/Library/Application Support/com.oracle.java.JavaAppletPlugin.plist',
'~/Library/Application Support/com.oracle.javadeployment.plist',
]
caveats do
license 'https://www.oracle.com/technetwork/java/javase/terms/license/javase-license.html'
end
end
Step-4
Now, install using brew:
brew cask install java8
Note: I got the SHA-256 checksum from the above mentioned java download link. You will have to change the version number, sha256 and
pkg sections to use the specific version you downloaded if it is not 8u231 like mine.
The command is
brew cask install adoptopenjdk8-openj9
Fixed my problem and I can run my project in java8
java -version
openjdk version "1.8.0_222
OpenJDK Runtime Environment (build 1.8.0_222-b10)
Eclipse OpenJ9 VM (build openj9-0.15.1, JRE 1.8.0 Mac OS X amd64-64-Bit Compressed References 20190717_298 (JIT enabled, AOT enabled)
OpenJ9 - 0f66c6431
OMR - ec782f26
JCL - f147086df1 based on jdk8u222-b10)
For some of the newer version of operating system, We can use following command:
brew install --cask homebrew/cask-versions/adoptopenjdk8
I have only managed to uninstall it with homebrew like this:
brew uninstall --ignore-dependencies java
brew install homebrew/cask-versions/adoptopenjdk8 --cask
==> Caveats
Temurin is the official successor to this software:
brew install --cask temurin8
adoptopenjdk8 has been officially discontinued upstream.
It may stop working correctly (or at all) in recent versions of macOS.
Using sdkma, it is little bit easier
Open a new terminal and enter
curl -s “https://get.sdkman.io" | bash
copy & paste the following in the terminal and enter
source "$HOME/.sdkman/bin/sdkman-init.sh"
It will install the SDKMAN in your machine.
Check the version of the SDKMAN
sdk version
See the available Java versions offered by SDKMAN
sdk list java
It will show all the available JDK from different vendors with supported versions.
Install parallel JDKs
install version 15: sdk install java 15.0.0-librca
install version 8: sdk install java 8.0.265-librca
Choose which one you want to use
sdk use java 8.0.265-librca
Ask the user to install Oracle JDK 8 instead of java8

error when running brew install elasticsearch and installing Java 1.7 on Yosemite

I'm trying to run
brew install elasticsearch
I keep getting this error
elasticsearch: Java 1.7+ is required to install this formula.
You can install with Homebrew Cask:
brew install Caskroom/cask/java
You can download from:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Error: An unsatisfied requirement failed this build.
I've run brew doctor, brew update, brew cleanup ect... and still keep getting this error. It appears it has something to do with a bug in Yosemite.
When I run
brew install Caskroom/cask/java
It says it's already installed. What give!
Does anyone know how to fix this?
This works for me
Install Java Mac
brew tap caskroom/cask
brew install brew-cask
brew cask install java
Install ES
brew update
brew install elasticsearch
brew info elasticsearch

Categories

Resources