Skip to Main Content

jni not supporting jdk 1.8

2926786Sep 4 2019

Hi All,

Does jdk 8 supports for jni also ?

Current case:

I’m building my project code using java 1.6 and ant 1.9, build is successful.


To build code on java 1.8 and ant 1.9


Using jdk 1.8 currently the build is failing for test written in C

The code called is jni code and failure point is code (*javaEnv)->FindClass(javaEnv, name); //not able to find the class file.Have manually verified that the .class file exists and jdk 1.8 is used in building that class.

on printing the exception using void ExceptionDescribe(JNIEnv *env);

Got exception:

Testing creation and use of custom properties...

Exception in thread "main" java.lang.UnsupportedClassVersionError: net/xyz/api/MyClass : Unsupported major.minor version 52.0

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

       at java.lang.ClassLoader.defineClass(Unknown Source)

       at Source)

       at Source)

       at$100(Unknown Source)

       at$ Source)

       at$ Source)

       at Method)

       at Source)

       at java.lang.ClassLoader.loadClass(Unknown Source)

       at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

       at java.lang.ClassLoader.loadClass(Unknown Source)

to check supported jni_version added code

#ifdef JNI_VERSION_1_4 

printf("Version is 1.4 \n");

#endif#ifdef JNI_VERSION_1_6 

printf("Version is 1.6 \n");

#endif#ifdef JNI_VERSION_1_8 

printf("Version is 1.8 \n");


Only 1.4 and 1.6 is printed and not 1.8

From .class file verified that major version is 52.

So what I understand is basically class is compiled using java 8 and jni is trying to run using java 6 which is causing this issue.

From oracle docs on jdk 8 jni

I see that only till IJDK/JRE 1.6, GetVersion() returns 0x00010006. is mentioned.

There is no reference of java 8

Where as in java 9 docs I see

both java 8 and java 9 for jni is defined.

Can any one help on how to fix this issue?

Post Details
Added on Sep 4 2019