Eclipse or a Java tool refuses to start with a JNI error
Error: A JNI error has occurred, please check your installation and try againShort answer
This message is only the headline. The line under it names the real problem. Most often it is UnsupportedClassVersionError: the program needs a newer Java than the one that started it. For Eclipse it can also be a 32-bit and 64-bit mismatch, or an eclipse.ini that points to the wrong Java.
Fix it fast
1Find out which cause you have
Print the Java version that the command line really uses, and where it lives. Compare it with the version the tool asks for.
java -version where java2Match what you see, then jump to its fix
- 1
java.lang.UnsupportedClassVersionError directly under the JNI lineThe Java on PATH is older than the program needsFix - 2
Eclipse will not open, or only the launcher error showsThe Eclipse release needs a newer Java than the one it foundFix - 3
The launcher fails right after you installed a new JDK32-bit Eclipse with a 64-bit Java, or the other way roundFix - 4
Java was started but returned exit code=1eclipse.ini points to a missing or wrong JavaFix
- 1
What does the error look like?
Error: A JNI error has occurred, please check your installation and try againException in thread "main" java.lang.UnsupportedClassVersionError:Java was started but returned exit code=1
Cause 1 of 4
The Java on PATH is older than the program needs
1Check
The program was built for a newer Java than the one that started it. Oracle's SQLcl documentation shows the same pair of lines when the installed Java is older than the version it requires, and tells you to check with java -version.
java -version2Fix
Install a JDK at or above the version the program documents, then make PATH (and JAVA_HOME, if the tool reads it) point to it.
setx JAVA_HOME "C:\Program Files\Java\jdk-21"
rem open a new terminal, then:
java -version3Verify
Run the program again from a new terminal. The JNI line must be gone.
java -versionConfirmed by docs.oracle.com
Cause 2 of 4
The Eclipse release needs a newer Java than the one it found
1Check
Eclipse 4.32 requires at least Java SE 17 and recommends Java SE 21. The EPP packages (the ready-made IDE downloads) need Java 21 to run correctly. The Eclipse SDK does not ship a Java runtime.
java -version2Fix
Install a Java 21 JDK, or newer if your Eclipse release notes ask for it, and tell Eclipse to use it in eclipse.ini (see the last cause).
-vm
C:\Program Files\Java\jdk-21\bin\javaw.exe3Verify
Start Eclipse; it opens without the launcher error.
java -versionConfirmed by eclipse.dev
Cause 3 of 4
32-bit Eclipse with a 64-bit Java, or the other way round
1Check
Eclipse and the JVM must have the same bit level. A 32-bit Eclipse cannot use a 64-bit JVM. Current Eclipse releases need a 64-bit JVM and do not support a 32-bit one.
java -version
rem compare with the Eclipse download you installed (32-bit or 64-bit)2Fix
Install the JDK that matches your Eclipse download, and download a 64-bit Eclipse if you are still on a 32-bit one.
rem reinstall: 64-bit Eclipse + 64-bit JDK3Verify
Eclipse opens without the launcher error.
java -versionConfirmed by wiki.eclipse.org
Cause 4 of 4
eclipse.ini points to a missing or wrong Java
1Check
The -vm option must be the full path to the Java executable, not only to the Java home folder. -vm and its path go on two separate lines, and -vm must come before -vmargs.
type "C:\eclipse\eclipse.ini"2Fix
Edit eclipse.ini so the two lines point to a real java executable of the right version. If the launcher still returns exit code 1, point the path to jvm.dll instead.
-vm
C:\Program Files\Java\jdk-21\bin\javaw.exe
-vmargs3Verify
Start Eclipse again.
rem double-click eclipse.exeConfirmed by wiki.eclipse.org
How do I stop it coming back?
- Write down the Java version each tool needs before you update it.
- Set -vm in eclipse.ini so Eclipse does not depend on whatever Java is first on PATH.
- Keep Eclipse and the JDK at the same bit level.
- After installing a new JDK, open a new terminal before testing, because old terminals keep the old PATH.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Back end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
The AWS SDK for Java cannot find credentials, and AwsCredentials.properties does nothing
software.amazon.awssdk.core.exception.SdkClientException: Unable to load credentials from any of the providers in the chain
AwsCredentials.properties on the classpath is an old convention: the default provider chain of the AWS SDK for Java does not read it.
4 causes, each with a fixBack end
Gradle runs no Cucumber scenarios from my feature files
Feature files exist under src/test but nothing runs
Cucumber runs on the JUnit Platform, so Gradle must call useJUnitPlatform() and have the cucumber-junit-platform-engine on the test classpath.
4 causes, each with a fixBack end
A Gradle build fails on classes that use Lombok annotations
Error: Annotation processors must be explicitly declared now.
Lombok is two things for Gradle: a compile-time library and an annotation processor.
3 causes, each with a fixBack end
Gradle 8 fails on Report destination: switch to outputLocation
What went wrong: 'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'
Gradle 8.0 removed the deprecated destination and enabled properties of the Report type.
2 causes, each with a fixBack end
Apache HttpClient 5 has no setSSLSocketFactory on HttpClients.custom()
HttpClients.custom().setSSLSocketFactory() method not found
In Apache HttpClient 5 the TLS setup no longer sits on the client builder.
2 causes, each with a fix