Blog

Python 3.7 And 2.7 Installation Steps On Windows 10

Changing python default versions on fedora 27?

Python websockets installation is failed on fedora linux

Network Basics

Document Clustering

Clustering Techniques

SQL Injection and Prevention Techniques

Google Form Intro and App Scripts

Download in Youtube using Youtube-dl commands

Java Network Launch Protocol File Launch Issue

javaws command is not working

Forcing Website with HTTPS instead of HTTP

Cricket Scores API's

Design Patterns

IIS Installation and Configuration on Windows 10

Unable to start debugging on the web server (IIS Error Code 405)

Google Chrome Installation on Fedora 26, CentOS / RHEL 7.4

Install Fedora 26 On Virtual Machine Using VirtualBox in Windows 10

Using screen command in fedora 25

Java JDK 1.8 Installation Steps On Windows 10

Enable Permanent SSH Access on Linux

C Program Undefined Reference Error

Curl error and couldn't resolve hostname fedora mirrors

Installing Android Studio in Windows 10

Resetting Root password on Fedora 26

Installing visual studio code editor steps for fedora 27 / centos 7 / RHEL 7

Java JNI Error UnsupportedClassVersionError in Windows 10

Install virt-customize in RHEL 8

Updating qcow2 image in RHEL 8

Remove the files from dir in another dir

Install virtualenv in RHEL 7

Install Scapy in RHEL 7

SQL ACID properties

Java JNI error UnsupportedClassVersionError in Windws 10



Windows 10 Error: A JNI error has occurred, Exception in thread "main" java.lang.UnsupportedClassVersionError

Let us consider this fibonacci series java program

import java.io.*;
public class Fibonacci
{
public static void main(String args[]) throws IOException
{
int n1=0,n2=1,n3,i,count;
DataInputStream dis=new DataInputStream(System.in);
System.out.println("enter the limit:");
count=Integer.parseInt(dis.readLine());
System.out.println(" "+n1);
System.out.println(" "+n2);
for(i=2;i<count;++i)
{
n3=n1+n2;
System.out.println(" "+n3);
n1=n2;
n2=n3;
}
}
}

During compilation,

E:\Java-app>javac Fibonacci.java
Note: FactorialNumber.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Running java program using class file,

E:\Java-app>java Fibonacci
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: FactorialNumber has been compiled by a more recent version of the Java Runtime (class file version 54.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)

We can come to know, the class version error. which means the class file is created using the compiler and runtime environment in machine are not same and compatible.

How to check javac and java vversions?

E:\Java-app>javac --version
javac 10.0.2
E:\Java-app>java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

In this environment, javac and java versions are not compatible each other and not same here.

javac version 10.0.2 and javac version 1.8.0_181

To fix the error, search and rename or remove either 1.8.0_181 java file or javac file of 10.0.2 in the environment.

Here we have renamed the 1.8.0_181 compiler file 'java' into 'java-new' in the environment to fix the java JNI UnsupportedClassVersionError error.

Java UnsupportedClassVersionError

Check the complier and java file versions again in the environment once renamed as above for java 1.8.0_181,

E:\Java-app>javac --version
javac 10.0.2
E:\Java-app>java -version
java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)

Let's run the java program again,

E:\Java-app>javac Fibonacci.java
Note: FactorialNumber.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

E:\Java-app>java Fibonacci
enter the limit:
4
 0
 1
 1
 2

Nice this time working fine.

 Blog

Python 3.7 And 2.7 Installation Steps On Windows 10

Changing python default versions on fedora 27?

Python websockets installation is failed on fedora linux

Network Basics

Document Clustering

Clustering Techniques

SQL Injection and Prevention Techniques

Google Form Intro and App Scripts

Download in Youtube using Youtube-dl commands

Java Network Launch Protocol File Launch Issue

javaws command is not working

Forcing Website with HTTPS instead of HTTP

Cricket Scores API's

Design Patterns

IIS Installation and Configuration on Windows 10

Unable to start debugging on the web server (IIS Error Code 405)

Google Chrome Installation on Fedora 26, CentOS / RHEL 7.4

Install Fedora 26 On Virtual Machine Using VirtualBox in Windows 10

Using screen command in fedora 25

Java JDK 1.8 Installation Steps On Windows 10

Enable Permanent SSH Access on Linux

C Program Undefined Reference Error

Curl error and couldn't resolve hostname fedora mirrors

Installing Android Studio in Windows 10

Resetting Root password on Fedora 26

Installing visual studio code editor steps for fedora 27 / centos 7 / RHEL 7

Java JNI Error UnsupportedClassVersionError in Windows 10

Install virt-customize in RHEL 8

Updating qcow2 image in RHEL 8

Remove the files from dir in another dir

Install virtualenv in RHEL 7

Install Scapy in RHEL 7

SQL ACID properties

Privacy Policy  |  Copyrightcopyright symbol2020 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter
^