Forum Stats

  • 3,827,149 Users
  • 2,260,746 Discussions


UnsupportedClassVersionError When Running JNI

Hello All,

I'm getting a UnsupportedClassVersionError error when calling FindClass() when running my C++ application on RedHat Linux.  We're a C++ shop and  we're using JNI in order to use a Java library given to us by a third party broker to interface with their systems.

The program had not been recompiled in a couple of years but recently an older C++ library that the program used was deprecated so we had to recompile this program.  But now when we try to run the program we're getting this error.

Exception in thread "main" java.lang.UnsupportedClassVersionError: TradingEngineWrapper : Unsupported major.minor version 52.0

        at java.lang.ClassLoader.defineClass1(Native Method)

        at java.lang.ClassLoader.defineClass(





        at Method)


        at java.lang.ClassLoader.loadClass(

        at sun.misc.Launcher$AppClassLoader.loadClass(

        at java.lang.ClassLoader.loadClass(

        at java.lang.ClassLoader.loadClassInternal(

I tried upgrading to a newer version of the JDK (jdk1.8.0_45) but that didn't help.  I know this is caused because our Java class library is compiled with one version but the JRE that is being invoked by the JNI is an incompatible version.  My question is, how do I control what version of the JRE that gets called when starting my C++ application?  Because I'm calling a C++ application I'm not starting it with "java app_name" or anything like that.  Any help would be appreciated.

Thank you.


  • jschellSomeoneStoleMyAlias
    jschellSomeoneStoleMyAlias Member Posts: 24,877 Gold Badge
    edited Jul 7, 2015 2:37PM

    First, your C++ app, with JNI, is being built with a specific library in use as part of the linker.  Insure that that library is the 'correct' java version.

    Second your C++ app runs but looking for the libraries via your OS dependent look up strategy for libraries (just like any other library).  Insure that the library it finds is for the 'correct' java version.  This of course should be the same as what you are using above.

    Finally make sure that you have not installed different versions of java into the same location.  Or worse, manually copied different parts of java (like random libraries) into unusual places.

This discussion has been closed.