Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Eclipse or a Java tool refuses to start with a JNI error

ErrorError: A JNI error has occurred, please check your installation and try again

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

  • Applies to Eclipse 4.32 and newer, Java 17, Java 21, Windows 11
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 java
  2. 2Match what you see, then jump to its fix

    1. 1java.lang.UnsupportedClassVersionError directly under the JNI lineThe Java on PATH is older than the program needsFix
    2. 2Eclipse will not open, or only the launcher error showsThe Eclipse release needs a newer Java than the one it foundFix
    3. 3The launcher fails right after you installed a new JDK32-bit Eclipse with a 64-bit Java, or the other way roundFix
    4. 4Java was started but returned exit code=1eclipse.ini points to a missing or wrong JavaFix

What does the error look like?

  • Error: A JNI error has occurred, please check your installation and try again
  • Exception 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 -version

2Fix

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 -version

3Verify

Run the program again from a new terminal. The JNI line must be gone.

java -version

Confirmed by docs.oracle.com

Did this fix it?

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 -version

2Fix

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

3Verify

Start Eclipse; it opens without the launcher error.

java -version

Confirmed by eclipse.dev

Did this fix it?

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 JDK

3Verify

Eclipse opens without the launcher error.

java -version

Confirmed by wiki.eclipse.org

Did this fix it?

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
-vmargs

3Verify

Start Eclipse again.

rem double-click eclipse.exe

Confirmed by wiki.eclipse.org

Did this fix it?

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

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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.