“A JNI error has occurred” — what it means and how to fix it (Minecraft & Java)

The full message — “A JNI error has occurred, please check your installation and try again” — stops Minecraft (and other Java programs) before they even open. The cause is almost boring: the program was built for a different Java version than the one it's being run with. Match the two and the error disappears.

What it means

Java programs are compiled for a minimum Java version. JNI is the bridge Java uses to talk to native code; the error appears when the Java runtime on the PC is too old (or otherwise mismatched) for the program asking to start. It became a household error when Minecraft 1.17+ moved to newer Java while millions of PCs still had Java 8 as the system default.

The fix, in order

  1. Work out which Java the program needs. For Minecraft: Java Edition 1.17–1.20.4 needs Java 16/17; 1.20.5 and newer need Java 21; versions before 1.17 (and most older modpacks) need Java 8. Server .jar files follow the same rules as their game version.
  2. Prefer the launcher's own Java first. The official Minecraft Launcher bundles the correct runtime for each version — if a custom launcher or a hand-made server shortcut is producing the error, try the official launcher before installing anything.
  3. Install the matching Java from a reputable source — Oracle, or the free builds at Adoptium (Eclipse Temurin). Installing a newer Java doesn't remove the old one; they coexist.
  4. Point the program at the right Java.
    • Minecraft Launcher: Installations → the installation → More Options → Java Executable → browse to the new Java's javaw.exe (usually under C:\Program Files\Java\ or the Adoptium folder).
    • Server or .jar shortcut: edit the launch command to use the full path, e.g. "C:\Program Files\Java\jdk-21\bin\java.exe" -jar server.jar.
    • Java Control Panel / JAVA_HOME: if several Java programs all misbehave, check the JAVA_HOME environment variable — an old value there overrides good installs.
  5. Remove ancient Java versions (Settings → Apps) once things work — Java 6/7-era leftovers are both a confusion source and a security risk.
Only download Java from Oracle or Adoptium. “Java download” search ads and bundle sites package old runtimes with junkware. And no separate “JNI fix tool” exists — version matching is the entire cure.

If it still happens

Check which Java actually ran: in Command Prompt, java -version shows the default. If it prints the wrong version after installing the right one, the PATH or JAVA_HOME still points at the old install — fix the variable (or use full paths in launch commands, which bypass it entirely). For Minecraft specifically, deleting the launcher's saved “runtime” choice and letting it re-download its bundled Java settles stubborn cases.

Common questions

Does this mean Java is broken? No — Java is fine; several versions are installed and the program picked (or was pointed at) the wrong one. Each version minds its own business once launch commands name the right one.

Is it safe to uninstall old Java? Yes, and usually wise. The exception is an old program that genuinely needs Java 8 — it will say so (with this very error) if it loses it, and Java 8 can be reinstalled alongside newer versions.

Related errors

Could not create the Java Virtual Machine · Runtime Error 5 · Visual C++ Runtime Library error