JNI failure on Linux

Discussion in 'Java' started by jimw, May 17, 2004.

  1. jimw

    jimw Guest

    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
     
    jimw, May 17, 2004
    #1
    1. Advertising

  2. jimw

    jimw Guest

    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" <> wrote in message
    news:A_Spc.23402$...
    > 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
    >
    >
     
    jimw, May 17, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

    Alex Hunsley, Nov 3, 2003, in forum: Java
    Replies:
    4
    Views:
    879
    Alex Hunsley
    Nov 4, 2003
  2. Pasturel Jean-Louis

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    943
    Pasturel Jean-Louis
    Mar 3, 2004
  3. vasanth
    Replies:
    0
    Views:
    2,780
    vasanth
    Jan 25, 2005
  4. Ilias Lazaridis
    Replies:
    0
    Views:
    626
    Ilias Lazaridis
    Feb 1, 2005
  5. Replies:
    0
    Views:
    516
Loading...

Share This Page