Fixing 'Unsupported OpenJDK' Error in VisualVM | Generated by AI
The error “Version of OpenJDK is not supported. Please use the default-jdk” when running VisualVM indicates that the Java Development Kit (JDK) version being used is not compatible with VisualVM. This issue is common when VisualVM cannot find a supported JDK or when the installed JDK is not properly configured. Below are steps to resolve this issue, based on the context of your setup (YourKit Java Profiler 2025.3 and VisualVM on what appears to be a Linux system).
Steps to Fix the Issue
- Check Your Current Java Version
Run the following command to verify the Java version installed:
java -version
This will display the OpenJDK version, such as:
openjdk version "17.0.9" 2023-10-17 OpenJDK Runtime Environment (build 17.0.9+9-Ubuntu-122.04) OpenJDK 64-Bit Server VM (build 17.0.9+9-Ubuntu-122.04, mixed mode, sharing)
VisualVM typically requires a JDK (not just a JRE) and supports Oracle JDK 8+ or compatible OpenJDK versions. Ensure you have a supported JDK installed.
- Install the Default JDK
The error suggests using the
default-jdk
. On Ubuntu/Debian, you can install it with:sudo apt update sudo apt install default-jdk
This typically installs a stable, supported OpenJDK version (e.g., OpenJDK 11 or 17). After installation, verify the version again with
java -version
. - Set JAVA_HOME Environment Variable
VisualVM relies on the
JAVA_HOME
environment variable to locate the JDK. Check if it’s set:echo $JAVA_HOME
If it’s not set or points to an unsupported JDK, set it to the correct JDK path. For example, if
default-jdk
installed OpenJDK 17, the path might be/usr/lib/jvm/java-17-openjdk-amd64
. Set it with:export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
To make this permanent, add the line to your
~/.bashrc
or~/.zshrc
:echo 'export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64' >> ~/.bashrc source ~/.bashrc
Replace the path with the actual JDK path on your system (use
update-alternatives --list java
to find it). - Specify JDK Path for VisualVM
If setting
JAVA_HOME
doesn’t resolve the issue, you can explicitly specify the JDK path when launching VisualVM:~/bin/YourKit-JavaProfiler-2025.3/bin/visualvm --jdkhome /usr/lib/jvm/java-17-openjdk-amd64
Replace
/usr/lib/jvm/java-17-openjdk-amd64
with the path to your JDK. This ensures VisualVM uses the specified JDK. - Install a Compatible JDK
If the
default-jdk
is still incompatible, consider installing a specific JDK version known to work with VisualVM, such as OpenJDK 11 or Oracle JDK 8+:sudo apt install openjdk-11-jdk
Then, update
JAVA_HOME
or use the--jdkhome
option as described above. - Check VisualVM Installation
Ensure VisualVM is correctly installed. The error suggests you’re running VisualVM from the YourKit Java Profiler directory (
~/bin/YourKit-JavaProfiler-2025.3/bin
). This is unusual, as VisualVM is typically a standalone tool or bundled with a JDK. Verify that VisualVM is not corrupted:- Download the latest VisualVM release from
visualvm.github.io/download.html
(e.g., VisualVM 2.2, released April 22, 2025, supports JDK 24). - Unzip it to a new directory and run it:
unzip visualvm_22.zip cd visualvm_22/bin ./visualvm --jdkhome /usr/lib/jvm/java-17-openjdk-amd64
Avoid unzipping over an existing VisualVM installation, as this can cause issues.
- Download the latest VisualVM release from
- Check for Multiple Java Installations
Multiple Java versions can cause conflicts. List all installed Java versions:
update-alternatives --list java
If multiple versions are listed, set the desired one as default:
sudo update-alternatives --config java
Select the number corresponding to the compatible JDK (e.g., OpenJDK 11 or 17).
- Verify VisualVM Dependencies
VisualVM requires
libnb-platform18-java
andlibvisualvm-jni
. Ensure these are installed:sudo apt install libnb-platform18-java libvisualvm-jni
This is particularly relevant if you installed VisualVM via
apt
. - Bypass OpenJDK Restrictions (Optional)
If you’re using an unsupported OpenJDK build (e.g., IcedTea or AdoptOpenJDK), profiling features may be limited. You can bypass some restrictions by adding a command-line argument:
./visualvm --jdkhome /usr/lib/jvm/java-17-openjdk-amd64 -J-Dorg.graalvm.visualvm.profiler.SupportAllVMs=true
This enables profiling for unsupported JVMs, though it’s not guaranteed to work perfectly.
- Check YourKit and VisualVM Compatibility
Since you’re running VisualVM from the YourKit Java Profiler directory, ensure YourKit’s environment isn’t interfering. YourKit Java Profiler 2025.3 may bundle a specific VisualVM version or configuration. Check YourKit’s documentation or contact
support@yourkit.com
to confirm compatibility with your JDK. Alternatively, try running VisualVM independently (downloaded separately) to isolate the issue.
Additional Notes
- YourKit Context: The error doesn’t directly relate to YourKit Java Profiler, but running VisualVM from YourKit’s directory suggests integration. YourKit supports Java 7–15 and later versions with EAP builds, so ensure your JDK is compatible with both tools if they’re used together.
- Log Files: Check VisualVM logs for more details. Logs are typically in
~/.visualvm/<version>/var/log
. For YourKit, check~/.yjp/log/
for profiler agent logs. If issues persist, send logs tosupport@yourkit.com
. - Alternative: If VisualVM continues to fail, consider using YourKit’s built-in profiling tools or another profiler like JProfiler or Async Profiler, which may have better compatibility with your setup.
If the Issue Persists
If none of the above resolves the issue, please provide:
- Output of
java -version
andecho $JAVA_HOME
. - Output of
update-alternatives --list java
. - The exact VisualVM version (check via
visualvm --help
or the download page). - Whether you’re using VisualVM bundled with YourKit or a standalone installation.
This will help pinpoint the issue further. You can also report the issue to the VisualVM GitHub page (https://github.com/oracle/visualvm
) or YourKit support for specific guidance.