Monday 17 August 2020

Root Cause & Solution Of The UnsupportedClassVersionError | Linux Only |...




Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: JavaProgram has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Commands:-
update-alternatives --config java
update-alternatives --config javac

Subscribe my Channel:-
http://www.youtube.com/user/SanketRooney?sub_confirmation=1

Facebook Page:-
https://www.facebook.com/UnpossibleNS

Twitter Account:-
https://twitter.com/UnpossiblePOG

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
Now we shall find out the root cause & solution of the UnsupportedClassVersionError which occurs while running java program for LINUX users only.
This thing occurs when we successfully compiles the code using javac command but throws an error when we run the program.
Lets create a program.
I am opening the terminal where our java file is present.
Now, there is nothing wrong with syntax, compiling is successful but this error is thrown.
The main reason is that we are using different JVM version for compiling and different JVM for running the code.
Don’t forget to add sudo before commands.
Type your password.
If we check runtime version, the version 8 is set.
Press enter or already set number.
However, if we check compiler version, the 11th version is set.
So to change it, enter the SELECTION number which is in front of it. In my case, its 2.
And now, if we recompile and execute, it shall work fine.
Code is given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching. 


No comments:

Post a Comment