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=HelloWorld Imp.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.Unsat isfiedLinkError : \
<obfuscated>/JNI_d/libhello.so: \
<obfuscated>/JNI_d/libhello.so: \
ELF file's phentsize not the expected size
at java.lang.Class Loader$NativeLi brary.load(Nati ve Method)
at java.lang.Class Loader.loadLibr ary0(ClassLoade r.java:1560)
at java.lang.Class Loader.loadLibr ary(ClassLoader .java:1485)
at java.lang.Runti me.loadLibrary0 (Runtime.java:7 88)
at java.lang.Syste m.loadLibrary(S ystem.java:834)
at HelloWorld.<cli nit>(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 <><><><><><><>< >
Comment