Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Fix Failed to Load the JNI Shared Library Error

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

The "Failed to load the JNI shared library" error usually appears when launching Java-based applications (like Eclipse, IntelliJ IDEA, or Android Studio) and means the Java Virtual Machine (JVM) cannot find a compatible Java Runtime Environment (JRE) or the wrong architecture (32-bit vs 64-bit) is installed. The fix is to install the correct Java version (matching your OS and app) and point the app to it. Below is a step-by-step guide to resolve it.

What You'll Need

  • Administrator access to your computer (to install Java and change system settings).
  • Knowledge of whether your Windows is 32-bit or 64-bit (check via Settings > System > About).
  • The Java version required by your application (check the app's documentation or its launch configuration).

Step-by-Step

  1. Identify the Java version and architecture your app needs. Most modern IDEs require 64-bit Java 8 or 11. If you're unsure, check the app's official system requirements. For Eclipse, for example, you need a 64-bit JRE if you're on 64-bit Windows.
  2. Check your current Java installation. Open a command prompt (Win+R, type cmd, press Enter) and run java -version. Note the version and whether it says "64-Bit" or "32-Bit". If it says "Unable to locate Java" or shows an error, Java may not be installed or not in your PATH.
  3. Uninstall any conflicting Java versions. Go to Control Panel > Programs > Programs and Features, and uninstall all Java entries that do not match the architecture you need. For example, if you have both 32-bit and 64-bit Java, remove the one that doesn't match your app.
  4. Download the correct Java version. Visit the official Oracle Java download page (or the vendor's site like Adoptium for OpenJDK). Choose the installer that matches your OS architecture (e.g., Windows x64 for 64-bit). Do not download from third-party sites.
  5. Install Java. Run the downloaded installer. During installation, note the installation path (e.g., C:\Program Files\Java\jdk-11.0.2). Make sure to select the option to set JAVA_HOME and add Java to PATH if prompted.
  6. Set the JAVA_HOME environment variable. Go to Control Panel > System > Advanced System Settings > Environment Variables. Under System variables, click "New" and set Variable name to JAVA_HOME and Variable value to your Java installation path (e.g., C:\Program Files\Java\jdk-11.0.2). Click OK.
  7. Update the PATH variable. In the same Environment Variables window, find the Path variable, select it, and click Edit. Add a new entry with %JAVA_HOME%\bin. Move it to the top if possible. Click OK to save.
  8. Restart your computer (or at least log off and back on) to apply the changes.
  9. Verify Java is correctly installed. Open a new command prompt and run java -version again. Confirm the version and architecture match what your app expects.
  10. Launch your application. Try starting your IDE or Java app. If it still fails, proceed to the next step.
  11. Specify the JVM path in the app's launch configuration. For Eclipse, open the eclipse.ini file (in the Eclipse installation folder) with a text editor. Add the following lines near the top, replacing the path with your actual Java path:
    -vm
    C:\Program Files\Java\jdk-11.0.2\bin\javaw.exe

    For IntelliJ IDEA, go to Help > Edit Custom VM Options and add the -javaagent or adjust the -jvm path if needed (but usually the system PATH is enough).
  12. Run the app as administrator (right-click the executable and select "Run as administrator") if you still see the error, as permission issues can cause JNI loading failures.

Common Mistakes

  • Installing a 32-bit Java on a 64-bit system (or vice versa) — always match the architecture.
  • Having multiple Java versions installed that conflict with each other.
  • Not setting JAVA_HOME correctly, or leaving the PATH without the bin folder.
  • Editing the eclipse.ini file incorrectly (e.g., putting the -vm line after -vmargs — it must be before).
  • Forgetting to restart the command prompt or the computer after changing environment variables.

Tips

  • Always download Java from official sources (Oracle, Adoptium, Microsoft OpenJDK) to avoid malware.
  • If you need multiple Java versions, use a tool like JDK's "alternatives" or manually switch JAVA_HOME each time — but for most users, one version is enough.
  • Check if your application has a 64-bit version that requires a 64-bit JVM — this is the most common cause of the error.
  • If you're on macOS or Linux, the error is less common, but the fix is similar: install the correct JDK via the system package manager or official installer, and set JAVA_HOME in your shell profile.

Troubleshooting

If the error persists after following the steps above:

  • Check the exact error message. Sometimes it includes the path to the missing .dll file. That path tells you which Java installation the app is trying to use. Ensure that path is correct and the file exists.
  • Reinstall the application. Uninstall the IDE or Java app completely, then reinstall it after Java is correctly set up. This can refresh the app's configuration.
  • Try a different Java version. Some apps require Java 8, others Java 11 or 17. If you have the wrong version, the JNI library may fail to load. Check the app's release notes or forums.
  • Run the app from the command line. Navigate to the app's installation folder and run the executable from a command prompt. This often shows more detailed error output that can help diagnose the issue.
  • Check for corrupted Java installation. Reinstall Java completely, making sure to remove all previous remnants (including registry entries on Windows).
  • If you are on a 64-bit system but only have 32-bit Java available, you must install a 64-bit JRE — there is no workaround.

Frequently Asked Questions

Why does the error say "Failed to load the JNI shared library"?

This means the Java Virtual Machine cannot locate the native library (like jvm.dll) that is required to run Java code. It usually happens when the Java version or architecture (32-bit vs 64-bit) does not match what the application expects.

Can I fix this without reinstalling Java?

Sometimes yes. You can try setting the JAVA_HOME variable and updating the PATH, or specifying the correct JVM path in the application's configuration file (like eclipse.ini). But if the installed Java is corrupted or the wrong architecture, a reinstall is the most reliable fix.

How do I know if I need 32-bit or 64-bit Java?

Check your Windows version: 64-bit systems can run both, but most modern applications require 64-bit Java. Look at the app's system requirements — if it says "64-bit", you need 64-bit Java. If you're unsure, try the 64-bit version first, as it's the standard now.

What if I have multiple Java versions installed?

Having multiple versions can cause conflicts. Uninstall all Java versions, then install only the one you need. Alternatively, you can set JAVA_HOME to point to the correct version, but the app may still use the first Java found in the PATH.

Does this error happen on macOS or Linux?

Yes, but it's less common. On those systems, the error usually says "Failed to load the JNI shared library" as well, and the fix is similar: install the correct JDK (e.g., via Homebrew on macOS or apt on Ubuntu) and set JAVA_HOME in your shell profile.

Will updating Java to the latest version fix the error?

Not necessarily. The error is more about matching the architecture and version that your application was built for. If your app requires Java 8, installing Java 17 might cause the error. Always check the app's requirements first.