인텔리 제이 A JNI error has occurred, please check your installation and try again

Hi, This is a common problem when you want to run a java program using the command line. The problem is occurring for so many reasons. Most of the cause is the different versions of the Java JDK and the Java JRE versions.

I have been having this problem for a while, but now I have figured it out.

It turns out that Java JDK 15 have both the JRE and the JDK inside the bin folder of the Java 15 JDK. (I have always believed that JRE and JDK are different application, but it turns out things have changed)

My problem was that I had Java JDK 15 installed on my computer

At the same time, I had Java 8 (JRE) installed on my computer.

So my computer is getting confused.

The error looks like:

Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

Solution:

Open the command prompt to check the version of the java and java compiler:

Typed the following commands:

java -version

// this gave me Java 8

After that, type

javac -version

// this gave me Java 15

인텔리 제이 A JNI error has occurred, please check your installation and try again
a JNI error has occurred please check your installation and try again Exception in thread main

In other words, my program is getting compiled with Java 15 and I am trying to run with Java 8. This is the problem of ” a JNI error has occurred please check your installation and try again Exception in thread main ……”

To solve the problem, I uninstalled Java 8 JRE from my computer.

Went back to the command prompt to check if “java -version” and “javac -version” are returning the same version number or not, In my case it’s yes, it is returning Java 15.

인텔리 제이 A JNI error has occurred, please check your installation and try again
a JNI error has occurred please check your installation and try again Exception in thread main

Tried recompiling my program, and running it. It Worked!!

인텔리 제이 A JNI error has occurred, please check your installation and try again
a JNI error has occurred please check your installation and try again Exception in thread main

Wow! It works fine. If not then comment……

Read more articles

터미널에서 클래스파일 실행하니까 에러

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

java.lang.UnsupportedClassVersionError: com/eomcs/lang/ex01/Exam0300 has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

인텔리 제이 A JNI error has occurred, please check your installation and try again

이클립스 컴파일러 JDK 버전이 더 높아서 에러 발생
이클립스 컴파일러 JDK 버전이랑 터미널 JDK 버전이랑 달라서 그런 거 같다

이클립스 컴파일러 버전

인텔리 제이 A JNI error has occurred, please check your installation and try again

인텔리 제이 A JNI error has occurred, please check your installation and try again

인텔리 제이 A JNI error has occurred, please check your installation and try again

이클립스와 동일한 버전의 JDK를 설치해준다

JDK설치
$ sdk install java 17.0.1-zulu

인텔리 제이 A JNI error has occurred, please check your installation and try again

설치가 다 되면 이 버전을 기본으로 설정할 거냐고 물어본다.
Do you want java 17.0.1-zulu to be set as default? (Y/n): y

이제 잘 된다ㅎㅎ