I'm trying to understand JNI well enough to be be able to supply
a state model class in C++ to some client applications and use the
same model in the JAVA app that controls the clients.
The state model class is written.
I thought a good place to start might be with the JAVA JNI Tutorial
HelloWorld instance, so I set up HelloWorld.java, compiled it, ran it
through javah, setup the HelloWorldImp.c ( native C language method )
and compiled it per the instructions ( or what the instructions implied ):
got HelloWorld.java
java HelloWorld.java
javah -jni HelloWorld
checked HelloWorld.h
got HelloWorldImp.c
Set LD_LIBRARY_PATH to the PWD since thats where everything resides
compiled HelloWorldImp.c as follow:
ZZZZ=HelloWorldImp.c
JJJJ=/usr/java/sdk ( 1.4.2_01 as it happens )
CPPOPT="-c -g -shared"
gcc $CPPOPT -I$JJJJ/include -I$JJJJ/include/linux $ZZZZ -o libhello.so
I am running on a RedHat 9 Linux box by the way.
Got the resulting libhello.so and then tried to run the app
java HelloWorld
What I got was:
Exception in thread "main" java.lang.UnsatisfiedLinkError: \
<obfuscated>/JNI_d/libhello.so: \
<obfuscated>/JNI_d/libhello.so: \
ELF file's phentsize not the expected size
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.jav a:1560)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1485)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at HelloWorld.<clinit>(HelloWorld.java:15)
No idea what this means although I suspect it has something to do with the
compilation of HelloWorldImp.c.
What have I done ( or not ) as the case may be.
Thanx.....
IBM
__________________________________________________ _____________________________
Posted Via Uncensored-News.Com - Accounts Starting At $6.95 -
http://www.uncensored-news.com
<><><><><><><> The Worlds Uncensored News Source <><><><><><><><>