Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JNI failure on Linux

Reply
Thread Tools

JNI failure on Linux

 
 
jimw
Guest
Posts: n/a
 
      05-16-2004
I previously posted this but hopefully I deleted it. This is a re-post.


On Linux, I'm having some problems with using Java/JNI from a C++ program
(actually
all C, just compiled as C++ with .cpp extension).

Using this JVM shared library:
/usr/java/jdk1.3.1_03/jre/lib/i386/server/libjvm.so - had to use the server
because if I use the client, I get the unresolved symbol "jdk_sem_post".
Read somewhere on the net that I should use the server version instead of
classic in order to avoid this issue.

I am able to resolve to libjvm.so and the symbol JNI_CreateJavaVM, but when
I call to create my VM, I get the following messages in my callback routine.

Error occurred during initialization of VM
Unable to load native library
libjvm.so: cannot open shared object file: No such file or directory

I'm thinking that libjvm.so has some dependency that is not being fulfilled,
but what????

"ldd libjvm.so" shows the following:
libnsl.so.1 => /lib/libnsl.so.1 (0x404fc000)
libdl.so.2 => /lib/libdl.so.2 (0x40513000)
libpthread.so.0 => /lib/libpthread.so.0 (0x40516000)
libstdc++-libc6.1-1.so.2 => /usr/lib/libstdc++-libc6.1-1.so.2
(0x4052c000)
libm.so.6 => /lib/libm.so.6 (0x4056e000)
libc.so.6 => /lib/libc.so.6 (0x4058e000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

A "strings libjvm.so" shows only the above .so files and also libhpi.so,
which
is apparently the native or green threads version. I also tried adding the
location of native_threads/libhpi.so to LD_LIBRARY_PATH and still no help.

My linus is a fairly old RedHat.
A uname shows "Linux linus 2.2.16-22 #11 SMP Tue Oct 2 18:02:55 EDT 2001
i686 unknown"

I link with "-lm -ldl -lbsd -lpthread"

The same code works OK on Win2K and also on Solaris 8.
I have standalone Java only code which is able to do JNDI and JMS with no
problem on this Linux machine.

Thanks for any help - I'm kinda baffled.

Jim



--

Gail


 
Reply With Quote
 
 
 
 
jimw
Guest
Posts: n/a
 
      05-17-2004
Never mind this one.
Solved it by adding the Java native_threads to my LD_LIBRARY_PATH and
adding -fPIC as a link flag. Found it on java.sun.com.

--


"jimw" <(E-Mail Removed)> wrote in message
news:A_Spc.23402$(E-Mail Removed). ..
> I previously posted this but hopefully I deleted it. This is a re-post.
>
>
> On Linux, I'm having some problems with using Java/JNI from a C++ program
> (actually
> all C, just compiled as C++ with .cpp extension).
>
> Using this JVM shared library:
> /usr/java/jdk1.3.1_03/jre/lib/i386/server/libjvm.so - had to use the

server
> because if I use the client, I get the unresolved symbol "jdk_sem_post".
> Read somewhere on the net that I should use the server version instead of
> classic in order to avoid this issue.
>
> I am able to resolve to libjvm.so and the symbol JNI_CreateJavaVM, but

when
> I call to create my VM, I get the following messages in my callback

routine.
>
> Error occurred during initialization of VM
> Unable to load native library
> libjvm.so: cannot open shared object file: No such file or directory
>
> I'm thinking that libjvm.so has some dependency that is not being

fulfilled,
> but what????
>
> "ldd libjvm.so" shows the following:
> libnsl.so.1 => /lib/libnsl.so.1 (0x404fc000)
> libdl.so.2 => /lib/libdl.so.2 (0x40513000)
> libpthread.so.0 => /lib/libpthread.so.0 (0x40516000)
> libstdc++-libc6.1-1.so.2 => /usr/lib/libstdc++-libc6.1-1.so.2
> (0x4052c000)
> libm.so.6 => /lib/libm.so.6 (0x4056e000)
> libc.so.6 => /lib/libc.so.6 (0x4058e000)
> /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
>
> A "strings libjvm.so" shows only the above .so files and also libhpi.so,
> which
> is apparently the native or green threads version. I also tried adding

the
> location of native_threads/libhpi.so to LD_LIBRARY_PATH and still no help.
>
> My linus is a fairly old RedHat.
> A uname shows "Linux linus 2.2.16-22 #11 SMP Tue Oct 2 18:02:55 EDT 2001
> i686 unknown"
>
> I link with "-lm -ldl -lbsd -lpthread"
>
> The same code works OK on Win2K and also on Solaris 8.
> I have standalone Java only code which is able to do JNDI and JMS with no
> problem on this Linux machine.
>
> Thanks for any help - I'm kinda baffled.
>
> Jim
>
>
>
> --
>
> Gail
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JNI thread vs. native thread vs. JNI call bgabrhelik Java 0 09-29-2009 03:33 PM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:03 AM
Re: JNI: Error loading DLL from JNI DDL vasanth Java 0 01-25-2005 11:01 AM
Porting JNI Windows under JNI LINUX + Wine ? Pasturel Jean-Louis Java 5 03-03-2004 07:50 PM
IBM's JNI fails where Sun's JNI works Alex Hunsley Java 4 11-04-2003 10:34 AM



Advertisments