aspose file tools*
The moose likes Linux / UNIX and the fly likes JNI problem in hp-ux 10.20 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "JNI problem in hp-ux 10.20" Watch "JNI problem in hp-ux 10.20" New topic
Author

JNI problem in hp-ux 10.20

Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Hi all:
I have a problem using jni in hp-ux 10.20. We are using jdk1.1.8. (these are project requirements).
In hp-ux 10.20, g++ is not working when we use jni...it is throwing UnsatisfiedLinkError. Could anyone help me how to use jni with g++ complier and ld linker in hp-ux 10.20?
I tried the alternate way to resolve this problem as follows:
jni works fine with the aCC compiler. In our project, many programs had been compiled using g++. So, what i thought was i would use aCC complier for the program that use jni and g++ for the remaining programs (since i can not compile all these programs using aCC for some other problems).
I would write here step by step what i had done...
Step 1: javac JNIExample.java
//this program invokes the native methods written in C++
Step 2: javah -jni JNIExample
//javah creates the header file JNIExample.h

Step 3: g++ -fpic -shared -c MyCPP.cpp
//this CPP program contains certain methods which are invoked by jniCPP.cpp
//the output of this step is MyCPP.o
Step 4:
/opt/aCC/bin/aCC +z +u4 -c $JNI_INCLUDE jniCPP.cpp
//this CPP program uses jni.h and defines methods (which are in JNIExample.h). I am using aCC complier so that it does not throw UnsatisfiedLinkError in hp-ux 10.20. since g++ compiler is not working in hp-ux 10.20 when we use jni
//the output of this step is jniCPP.o
Step 5:
ld -b -o libServer.sl jniCPP.o MyCPP.o
//link using 'ld' and create a shared library libServer.sl
//this library had been loaded in JNIExample.java
Step 6:
java JNIExample
//execute the program which invokes the native method
When i do Step 6, i get the following error:
/usr/lib/dld.sl: Unresolved symbol: __nw__FUi (code) from libServer.sl
SIGABRT 6* abort (generated by abort(3) routine)
Sig = 6; code = -1.
stackbase=79D7F000, stackpointer=79D7F1C0
Abort(coredump)

What i feel is: I used ( aCC compiler & produced one object file ) and also ( used g++ compiler & produced one object file)...so it could not link these two object files...i don't know what i am thinking is correct or not?
Could anyone please give me the solution either (to use g++ complier for jni successfully in hp-ux 10.20) or ( to resolve the problem occured when using aCC and g++ compilers)
Thanks a lot in advance...
Uma
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
I figured out the problem long back...just posting it over here...
1) The g++ compiler and aCC compiler use different name mangling scheme...So, it is NOT possible to link both these object files.
2) hp unix 10.20 does not support JNI with g++ compiler
3) hp unix 10.20 does not support STL
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Which make sense why you are now looking at Runtime.exec(). Sorry we couldn't be more help, but I guess we don't have anyone here who is familiar enough with HPUX.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Uma Viswanathan
Ranch Hand

Joined: Jun 14, 2001
Posts: 126
Hi Frank Carver:
I had finished that work long back...since i was in a position to use (must use) g++ complier, i had written the code in C++ (socket programming) on hp-ux 10.20 [instead of jni]
I was looking for Runtime.exec() for the following reason:
A script should start the client and (servers, if loopback address)...i had written a java program to read an ini file and to start the servers (an exe and a .class files) using Runtime.exec()...the script will execute this java program in addition to some other works.
Thanks a lot for your helps.
Uma
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNI problem in hp-ux 10.20