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. Advertisements

  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. Advertisements

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. Ilghiz Ibraghimov

    JNI linux problems

    Ilghiz Ibraghimov, Aug 28, 2003, in forum: Java
    Replies:
    3
    Views:
    4,343
    Ilghiz Ibraghimov
    Aug 28, 2003
  2. Alex Hunsley

    IBM's JNI fails where Sun's JNI works

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

    Porting JNI Windows under JNI LINUX + Wine ?

    Pasturel Jean-Louis, Feb 29, 2004, in forum: Java
    Replies:
    5
    Views:
    1,197
    Pasturel Jean-Louis
    Mar 3, 2004
  4. vasanth
    Replies:
    0
    Views:
    3,258
    vasanth
    Jan 25, 2005
  5. Ilias Lazaridis
    Replies:
    0
    Views:
    875
    Ilias Lazaridis
    Feb 1, 2005
  6. Venky
    Replies:
    0
    Views:
    455
    Venky
    Nov 30, 2005
  7. bgabrhelik
    Replies:
    0
    Views:
    1,168
    bgabrhelik
    Sep 29, 2009
  8. Steven D'Aprano

    distutils bdist_wininst failure on Linux

    Steven D'Aprano, Feb 23, 2012, in forum: Python
    Replies:
    4
    Views:
    470
    Bob Bowles
    Aug 6, 2012
Loading...