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.
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.
javaw.exe (usually under C:\Program Files\Java\ or the Adoptium folder)."C:\Program Files\Java\jdk-21\bin\java.exe" -jar server.jar.JAVA_HOME environment variable — an old value there overrides good installs.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.
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.