javamacossdkman

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?


Solution

  • 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.