From 2ee7dcd7a0fb229ababcf4622f87f69a9054eba9 Mon Sep 17 00:00:00 2001 From: Ahmad Ansori Palembani Date: Mon, 8 Jul 2024 12:55:03 +0700 Subject: [PATCH] feat: Script for SDKMAN! java setup on macOS macOS find JAVA_HOME differently than other OS for some reason, and it doesn't seems to be documented either, but basically macOS will detect latest JVM(Platform) in "/Library/Java/JavaVirtualMachines" (or "~/Library/Java/JavaVirtualMachines"). To do detect the version they look up Info.plist in "/Contents", if it's the newest it then print the "Home" dir path of that distro. (e.g. "/Users//Library/Java/JavaVirtualMachines/zulu-13.0.0/Contents/Home") Not sure why SDKMAN! didn't handle this themselves, but whatever. This solve my issue when trying to run KMM iOS App REF: https://stackoverflow.com/questions/76523553/how-to-make-usr-libexec-java-home-find-jdk-installed-using-sdkman-on-macos --- sdkman-darwin-setup | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 sdkman-darwin-setup diff --git a/sdkman-darwin-setup b/sdkman-darwin-setup new file mode 100755 index 0000000..d31001a --- /dev/null +++ b/sdkman-darwin-setup @@ -0,0 +1,26 @@ +#!/bin/sh + +mkdir -p "$HOME/Library/Java/JavaVirtualMachines/sdkman-current/Contents" +ln -si $HOME/.sdkman/candidates/java/current "$HOME/Library/Java/JavaVirtualMachines/sdkman-current/Contents/Home" + +echo " + + + + CFBundleIdentifier + sdkman.current + CFBundleName + SDKMAN Current JDK + JavaVM + + JVMPlatformVersion + 9999 + JVMVendor + Homebrew + JVMVersion + 9999 + + +" > "$HOME/Library/Java/JavaVirtualMachines/sdkman-current/Contents/__tmp" +mv -i "$HOME/Library/Java/JavaVirtualMachines/sdkman-current/Contents/__tmp" "$HOME/Library/Java/JavaVirtualMachines/sdkman-current/Contents/Info.plist" +rm "$HOME/Library/Java/JavaVirtualMachines/sdkman-current/Contents/__tmp" 2>/dev/null