Skip to content

Instantly share code, notes, and snippets.

@gavvvr
Last active May 19, 2023 01:59
Show Gist options
  • Save gavvvr/c9891684f9ef062502d58c80903be5cc to your computer and use it in GitHub Desktop.
Save gavvvr/c9891684f9ef062502d58c80903be5cc to your computer and use it in GitHub Desktop.
Getting visualvm on OSX with SDKMAN!

UPDATE:

Now you can just install Liberica JDK pkg-distibution using brew and will never face the problem mentioned below:

brew tap bell-sw/liberica
brew cask install liberica-jdk11

Usually I do not have Oracle Java installed on my OSX with Apple/Oracle installer. To manage Java and other JVM tools versions I use SDKMAN!.

So I had both VisualVM (sdk i visualvm 1.4.1) and Java (sdk i . java 8.0.181-zulu) installed with SDKMAN.

Then I wanted to start VisualVM with visualvm command and got a message:

Unable to find any JVMs matching version "1.8.0+". Cannot find java. Please use the --jdkhome switch.

Such error often happens when you have Java installed locally and OSX does not really know about it, only your shell knows.

The solution for the problem is usually to edit configuration file of desired program to explicitly point to Java path. In this particular case first locate the visualvm path, which visualvm:

~/.sdkman/candidates/visualvm/current/bin/visualvm

You can also find a configuration file near here located at:

~/.sdkman/candidates/visualvm/current/etc/visualvm.conf

Open it, find the visualvm_jdkhome and uncomment it providing a correct path to JDK, in my case:

/Users/user/.sdkman/candidates/java/8.0.181-zulu

That's it, now you can use VisualVM

@ishults
Copy link

ishults commented Dec 4, 2019

You saved me a lot of time, thank you for posting this!

@paraita
Copy link

paraita commented Jan 19, 2020

Thanks mate that's been real helpful

@sorinstanila
Copy link

sorinstanila commented Jun 8, 2020

Looking at the configuration file, I saw you can set this a parameter. Works nice
visualvm --jdkhome ~/.sdkman/candidates/java/current

@xu747
Copy link

xu747 commented May 19, 2023

Good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment