Fixing 'Unsupported OpenJDK' Error in VisualVM | Generated by AI

Home PDF

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

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

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

  3. 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).

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

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

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

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

  8. Verify VisualVM Dependencies VisualVM requires libnb-platform18-java and libvisualvm-jni. Ensure these are installed:
    sudo apt install libnb-platform18-java libvisualvm-jni
    

    This is particularly relevant if you installed VisualVM via apt.

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

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

If the Issue Persists

If none of the above resolves the issue, please provide:

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.


Back 2025.06.27 Donate