Error message - Incompatible JNI version
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   z_z
Posted On:   Friday, February 9, 2007 07:43 PM

Hello all, I am using JDK 1.5.0 on windows XP platform. java -version gives me.... java version "1.5.0" Java(TM) 2 Runtime Environment, Standard Edition (build pwi32dev-20060511 (SR2)) IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223-2006050 4 (JIT enabled) J9VM - 20060501_06428_lHdSMR JIT - 20060428_1800_r8 GC - 20060501_AA) JCL - 20060511a I am trying to write a simple Java program which makes a call to a native C code compiled using the free lccwin32 compiler. Steps I   More>>

Hello all,


I am using JDK 1.5.0 on windows XP platform.


java -version gives me....


java version "1.5.0"


Java(TM) 2 Runtime Environment, Standard Edition (build pwi32dev-20060511 (SR2))



IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223-2006050


4 (JIT enabled)


J9VM - 20060501_06428_lHdSMR


JIT - 20060428_1800_r8


GC - 20060501_AA)


JCL - 20060511a



I am trying to write a simple Java program which makes a


call to a native C code compiled using the free lccwin32


compiler.


Steps I followed.


1. Compiled the java program using javac


2. Created the header file using javah


3. Compiled the C code with lcc


4. Created a DLL using lcclnk


5. Ran the java program


I get the following error message.



Exception in thread "main" java.lang.UnsatisfiedLinkError:

samplejni (Incompatible JNI version (not 1.1, 1.2 or 1.4))
at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:953)
at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:922
)
at java.lang.System.loadLibrary(System.java:451)
at samplejni.main(samplejni.java:8)


My program name is samplejni.java and samplejni.c


I am giving the source code in case someone needs to look at that.


**********************************
samplejni.java


public class samplejni


{


public native int square(int x);


public static void main(String[] args)


{


System.loadLibrary("samplejni");


samplejni sample = new samplejni();


int x = 25;


int sq = sample.square(x);


System.out.println("Square of " + x + " " + sq);


}


}


***************************************


samplejni.c


#include


#include "samplejni.h"


#include


JNIEXPORT jint JNICALL Java_samplejni_square(JNIEnv *env, jobject obj, jint num)


{


return num*num;


}


JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
return 0;
};


JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
{
}


**************************************


samplejni.h


/* DO NOT EDIT THIS FILE - it is machine generated */
#include
/* Header for class samplejni */


#ifndef _Included_samplejni


#define _Included_samplejni


#ifdef __cplusplus


extern "C" {
#endif


/*
* Class: samplejni
* Method: square
* Signature: (I)I
*/


JNIEXPORT jint JNICALL Java_samplejni_square
(JNIEnv *, jobject, jint);


#ifdef __cplusplus


}


#endif


#endif


*************************************

   <<Less
About | Sitemap | Contact