Skip to content

Instantly share code, notes, and snippets.

@niqdev
Created March 11, 2025 15:28
Show Gist options
  • Save niqdev/81672090a63196967e24eea93004d0fe to your computer and use it in GitHub Desktop.
Save niqdev/81672090a63196967e24eea93004d0fe to your computer and use it in GitHub Desktop.
VisualVM with SDKMAN
# related issue/fix
https://github.com/oracle/visualvm/issues/152
https://stackoverflow.com/questions/76523553/how-to-make-usr-libexec-java-home-find-jdk-installed-using-sdkman-on-macos
# ISSUE the gui opens and shutdown immediately
brew install --cask visualvm
# verify issue
/usr/libexec/java_home
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
# verify sdkman path
echo $JAVA_HOME
/opt/homebrew/opt/sdkman-cli/libexec/candidates/java/current
# solution
sudo mkdir -p /Library/Java/JavaVirtualMachines/sdkman-current/Contents
sudo ln -s $JAVA_HOME /Library/Java/JavaVirtualMachines/sdkman-current/Contents/Home
sudo vim /Library/Java/JavaVirtualMachines/sdkman-current/Contents/Info.plist
# c&p content
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>sdkman.current</string>
<key>CFBundleName</key>
<string>SDKMAN Current JDK</string>
<key>JavaVM</key>
<dict>
<key>JVMPlatformVersion</key>
<string>9999</string>
<key>JVMVendor</key>
<string>Homebrew</string>
<key>JVMVersion</key>
<string>9999</string>
</dict>
</dict>
</plist>
# verify fix
/usr/libexec/java_home -V
Matching Java Virtual Machines (1):
9999 (arm64) "Homebrew" - "SDKMAN Current JDK" /Library/Java/JavaVirtualMachines/sdkman-current/Contents/Home
/Library/Java/JavaVirtualMachines/sdkman-current/Contents/Home
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment