Jni issues linux

I am trying to run a simple jni program fron this site "http://public.cabit.wpcarey.asu.edu/janjua/java/jni/ " on Red Hat Enterprise Linux AS release 4 and jdk 1.5.09 , AMD opteron. But when i run the command "gcc -I /usr/java/jdk1.5.0_09/include/ -I /usr/java/jdk1.5.0_09/include/linux/ -shared -o libhelloNative.so helloNative.c" i get the following error
/usr/bin/ld: /tmp/ccOjRonK.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/tmp/ccOjRonK.o: could not read symbols: Bad value
can anyone tell me a fix for this , I had no problem running the same program on Redhat Linux workstaion 3 with intel xeon processor
Thanks

I am trying to run a simple jni program fron this
site
"http://public.cabit.wpcarey.asu.edu/janjua/java/jni/
" on Red Hat Enterprise Linux AS release 4 and jdk
1.5.09 , AMD opteron. But when i run the command
"gcc -I /usr/java/jdk1.5.0_09/include/ -I
/usr/java/jdk1.5.0_09/include/linux/ -shared -o
libhelloNative.so helloNative.c" i get the
following error
/usr/bin/ld: /tmp/ccOjRonK.o: relocation R_X86_64_32
against `a local symbol' can not be used when making
a shared object; recompile with -fPIC
/tmp/ccOjRonK.o: could not read symbols: Bad value
can anyone tell me a fix for this , I had no problem
running the same program on Redhat Linux workstaion
3 with intel xeon processorWas the xeon processor 64 bit?
This isn't a JNI problem, its a 64 bit vs 32 bit problem.
Thanks

Similar Messages

  • Progblems Running a C program with JNI on Linux

    Hi
    We are having a problem running a C program which uses JNI to start a virtual machine.
    We can compile it up ok and it finds all the correct libraries and everything is fine as far as we are aware but when we try to run the program the error we get is "command not found". Now when the same programm is compiled with out JNI stuff, so basically no java at all it compiles and runs ok.
    I was wondering if anyone else has had similar problems we are using sun jdk 1.3.1 and RedHat Linux 7.2.
    Thanks
    Iain

    Hi
    We are having a problem running a C program which uses
    JNI to start a virtual machine.
    We can compile it up ok and it finds all the correct
    libraries and everything is fine as far as we are
    aware but when we try to run the program the error we
    get is "command not found". Now when the same
    programm is compiled with out JNI stuff, so basically
    no java at all it compiles and runs ok.
    I was wondering if anyone else has had similar
    problems we are using sun jdk 1.3.1 and RedHat Linux
    7.2.
    Thanks
    IainHi !
    I think I had the same problem. But fortunately I found the solution.
    I tried to compile and run the standard sun example of invocation interface. My C file is main.c.
    Compilation:
    cc -I/usr/java/jdk1.3.1/include/linux -L/usr/java/jdk1.3.1/jre/lib/i386/classic/ -L/usr/java/jdk1.3.1/jre/lib/i386/native_threads/ -lpthread -lhpi -ljvm main.c
    after then You must create the environment variable LD_LIBRARY_PATH and point out Your JNI libraries location. That works with mine.
    LD_LIBRARY_PATH=/usr/java/jdk1.3.1/jre/lib/i386:/usr/java/jdk1.3.1/jre/lib/i386/native_threads:/usr/java/jdk1.3.1/jre/lib/i386/classic;export LD_LIBRARY_PATH
    Now it should work.

  • How to Use JNI for linux based C programs

    Hi all,
    I am doing my project in JAVA for my Institute. There is a Central server. All the API's have written in C. The C APIs are Linux based.
    The problem is getting records from the database through API.
    I tried the Java Native Methods. I am able to do that in console with out problem. Since my project is web based I want to fetch the records through the C APIs in JSP. Is it possible? How to do that?
    Please Help me.
    -Prathap

    Why can't you use JDBC?
    I tried the Java Native Methods. I am able to do that in console with out problem. Since my project is web based I want to fetch the records through the C APIs in JSP. Is it possible? How to do that?JSP runs in a server. Which is just a big console application. Same as any other.
    Basic process.
    1. Write the JNI
    2. Insure the JNI is in the servers shared library path. This can depend on the user that the server runs under (unlikely to be you.)
    3. Add the java code into the server.

  • Setup PeopleTools 8.53 Database Issue (Linux Version)

    Folk,
    Hello. I am installing PeopleTools 8.53 Internet Architecture. Database Server is Oracle Dabase 11gR1. OS is Oracle Linux 5.
    I have installed JDK7, WebLogic 10.3.6, Tuxedo 11gR1 and PeopleTools 8.53 successfully. But when set up PeopleTools8.53 Database in the way as below,
    I get an error message and cannot proceed.
    [user@localhost PT8.53]$ pwd
    /opt/PT8.53
    [user@localhost PT8.53]$ ls
    AppBatchDBORA     dict                        psconfig.sh     setup
    AppBatchDBWebExe  etc                         PSEMAgent       sqr
    appserv           fonts                       PSEMViewer      src
    bin               jre                         readme.txt      toolsadmin.sh
    cblbin            jre1.7.0                    scripts         utility
    ccr               log                         sdk             web
    class             PeopleTools_InstallLog.log  SecurityAddIns
    data              peopletools.properties      secvault
    [user@localhost PT8.53]$ ./psconfig.sh
    [user@localhost PT8.53]$ cd setup
    [user@localhost setup]$ ls
    ccr                     pscbl.mak                PsTestFramework
    Client                  pscbl_mf.mak             pstuxftp.txt
    dashboard               PsCIA                    psvccrt
    dbcodes.pt              psdb.sh                  ptib.jar
    dotnetredist            psdmtx.cfg               readonly.txt
    endorsed                psmkreadonly.sh          searchCobolPgms.ps
    NOTESDB                 psmkwritable.sh          soap
    nVisionDrill            PsMpCrystalInstall       unicode.cfg
    OpenXmlSDK              PsMpDbInstall            unpack_jre.sh
    parmfile                PsMpPIAInstall           UPGCOMPVIEWER
    peopletools_ab_reg.cfx  PsMpWebAppDeployInstall  WebCenter
    pkgs                    PSODBC                   writable.txt
    PsCA                    psrun.mak
    [user@localhost setup]$ cd PsMpDbInstall
    [user@localhost PsMpDbInstall]$ ls
    InstData  setup.bat  setup.sh
    [user@localhost PsMpDbInstall]$ ./setup.sh
    Setting temporary directory /tmp/IA.6736
    Executing setup.linux LAX_VM /opt/PT8.53/jre/bin/java  -DCOMP_NAME=localhost.localdomain -DPS_UMASK=0002
    Preparing to install...
    Extracting the installation resources from the installer archive...
    Configuring the installer for this system's environment...
    Launching installer...
    ===============================================================================
    Peoplesoft Database Configuration                (created with InstallAnywhere)
    Preparing CONSOLE Mode Installation...
    ===============================================================================
    Welcome
    Welcome to the PeopleSoft Database Configuration Wizard 8.53
    This Wizard will assist you in configuring and loading a PeopleSoft database.
    PRESS <ENTER> TO CONTINUE:
    ===============================================================================
    Error
    You must run psconfig.sh (. ./psconfig.sh) under your PS_HOME directory before
    starting the Database Configuration Wizard.
    PRESS <ENTER> TO ACCEPT THE FOLLOWING (OK):
    [user@localhost PsMpDbInstall]$
    As you see the above, I have run ./psconfig.sh in the directory /opt/PT8.53 and then run ./setup.sh in the directory /opt/PT8.53/setup/PsMpDbInstall.
    but get the error message:
    "You must run psconfig.sh (. ./psconfig.sh) under your PS_HOME directory before starting the Database Configuration Wizard."
    I have run the 2 commands ./psconfig.sh and ./setup.sh in root but get the same error message.
    My question is: Does PeopleTools8.53 Linux Version have a problem ? How to solve the issue ?
    Thanks.

    Folks,
    Hello. Thanks a lot for replying.
    . ./psconfig.sh has gone through. Now, I get new issues as below:
    [root@localhost PsMpDbInstall]# pwd
    /opt/PT8.53/setup/PsMpDbInstall
    [root@localhost PsMpDbInstall]# ./setup.sh
    Setting temporary directory /tmp/IA.30567
    Executing setup.linux LAX_VM /opt/PT8.53/jre/bin/java  -DCOMP_NAME=localhost.localdomain -DPS_UMASK=0022
    Preparing to install...
    Extracting the installation resources from the installer archive...
    Configuring the installer for this system's environment...
    Launching installer...
    ===============================================================================
    Peoplesoft Database Configuration                (created with InstallAnywhere)
    Preparing CONSOLE Mode Installation...
    ===============================================================================
    Welcome
    Welcome to the PeopleSoft Database Configuration Wizard 8.53
    This Wizard will assist you in configuring and loading a PeopleSoft database.
    PRESS <ENTER> TO CONTINUE:
    ===============================================================================
    Please enter an installation location or press <ENTER> to accept the default
       (DEFAULT: /opt/PT8.53):
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
    Note: If you have installed PeopleSoft Applications outside PeopleTools PS_HOME
    then choose the PeopleSoft Applications home PS_APP_HOME, else leave the
    default PS_HOME.
    Choose the directory where you previously installed PeopleSoft Applications,
       commonly known as PS_APP_HOME.  or press <ENTER> to accept the default
       (DEFAULT: /opt/PT8.53):
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
    For a database platform of 'Oracle', are you installing a:
        1- Non-Unicode Database
      ->2- Unicode Database
    To select an item enter its number, or 0 when you are finished [0] : 0
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    Oracle - UNICODE
    ===============================================================================
    Select Character Set:
      ->1- AL32UTF8      
        2- UTF8          
    To select an item enter its number, or 0 when you are finished [0] : 0
    Database Create Type:
      ->1- PeopleTools System
    To select an item enter its number, or 0 when you are finished [0] : 0
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
    Select PeopleSoft Application:
      ->1- PeopleTools System Database - US English
    To select an item enter its number, or 0 when you are finished [0] : 0
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
       Specify the directory path for 'sqlplus' [/products/oracle/9.2.0/bin]: /home/user/OracleDB_Home/bin
       Specify the location for ORACLE_HOME [/products/oracle/9.2.0]: /home/user/OracleDB_Home/bin
    Location of modified scripts: /opt/PT8.53/modifiedscripts
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
    Do you want to create a new SID or use existing one?
      ->1- Create new SID
        2- Use existing SID
    To select an item enter its number, or 0 when you are finished [0] : 2
    Do you want to create a new SID or use existing one?
        1- Create new SID
      ->2- Use existing SID
    To select an item enter its number, or 0 when you are finished [0] : 0
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
       Oracle SID [PTSYS]: DB1
       DatabaseName [PTSYS]: PT853
       Mount Point 1( for SYSTEM and REDO LOGS file in createdb.sql, ex: NT 'C'  ,
       UNIX 'u01') [c]: u01
       Mount Point 2 ( for PSTEMP and PSDEFAULT file in utlspace.sql, ex: NT 'C'  ,
       UNIX 'u01') [c]: u01
       Mount Point 3 ( for all files in xxddl.sql, ex: NT 'C'  , UNIX 'u01') [c]: u01
    Enable AutoExtend for Peoplesoft Tablespaces?
      ->1- Yes
        2- No
    To select an item enter its number, or 0 when you are finished [0] : 0
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
       Peoplesoft owner ID (ex: 'SYSADM') [SYSADM]: SYSADM
       Peoplesoft owner password (ex: 'SYSADM') []:      
       Peoplesoft owner password Re-type []:      
       Peoplesoft connect ID [people]: people
       Peoplesoft connect password []:      
       Peoplesoft connect password Re-type []:      
       Peoplesoft default tablespace  (ex: 'PSDEFAULT') [PSDEFAULT]: PSDEFAULT
       Location of init.ora file complete path
       [/home/user/OracleDB_Home/bin/dbs/initDB1.ora]:
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 2
    ===============================================================================
       Oracle SID [DB1]:
       DatabaseName [PT853]:
       Mount Point 1( for SYSTEM and REDO LOGS file in createdb.sql, ex: NT 'C'  ,
       UNIX 'u01') [u01]:
       Mount Point 2 ( for PSTEMP and PSDEFAULT file in utlspace.sql, ex: NT 'C'  ,
       UNIX 'u01') [u01]:
       Mount Point 3 ( for all files in xxddl.sql, ex: NT 'C'  , UNIX 'u01') [u01]
    Enable AutoExtend for Peoplesoft Tablespaces?
      ->1- Yes
        2- No
    To select an item enter its number, or 0 when you are finished [0] :
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] :
    ===============================================================================
    Please enter the Appserver User and Password for your database.
       Appserver User []: tlisten
       Password []:       
       Re-type Password []:       
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
    Please enter the Webserver User and Password for your database.
       Webserver User : PTWEBSERVER
       Password []:           
       Re-type Password []:           
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
    Choose whether to enable or disable all other user profiles in your database.
      ->1- Disable
        2- Enable
    To select an item enter its number, or 0 when you are finished [0] : 2
    Choose whether to enable or disable all other user profiles in your database.
        1- Disable
      ->2- Enable
    To select an item enter its number, or 0 when you are finished [0] : 0
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
    Choose whether to set the password same as the OPRID (user) or a different
    password (a global password, same for all OPRIDs).
      ->1- Set the password same as OPRID
        2- I would like to set a different password
    To select an item enter its number, or 0 when you are finished [0] : 0
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
    Select Base Lanaguage
      ->1- ENG - US English                       
    To select an item enter its number, or 0 when you are finished [0] : 1
    Select Base Lanaguage
      ->1- ENG - US English                       
    To select an item enter its number, or 0 when you are finished [0] : 0
    Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1] : 1
    ===============================================================================
    Pre-Installation Summary
    Please Review the Following Before Continuing:
    Product Name:
        Peoplesoft Database Configuration
    Install Folder:
        /opt/PT8.53
    Apps Install Home:
        /opt/PT8.53
    Database Platform:
        Oracle  -  Unicode
    Oracle SID:
        DB1
    Application:
              PeopleTools System Database - US English
    Database Name:
        PT853
    Please type 'back' to go to previous panels
    PRESS <ENTER> TO CONTINUE:
    ===============================================================================
    Installing...
    [==================|==================|==================|==================]
    [------------------|------------------|------------------|------------------]
    ===============================================================================
    Please Wait...
    Executing.. /opt/PT8.53/modifiedscripts/psadmin.sql.
    ===============================================================================
    Please Wait...
    Executing.. /opt/PT8.53/modifiedscripts/connect.sql.
    ===============================================================================
    Executing DM: -CT ORACLE -CS localhost.localdomain -CD PT853 -CO SYSADM -CP
    SYSADM -CI people -CW people -FP /opt/PT8.53/modifiedscripts/dbsetup.dms
    Console Mode: true
    Initializing Data Mover ... please wait
    Console DM Mode: /opt/PT8.53/bin/psdmtx /opt/PT8.53/setup/parm1
    Error: unable to terminate process
    ExitCode: 127
    Error: true
    ===============================================================================
    Error
    The following error occurred while running data mover .
    Error: File not found: /opt/PT8.53/scripts/pt853ora.dms
    Please select OK to exit installer.
    PRESS <ENTER> TO ACCEPT THE FOLLOWING (OK):
    ===============================================================================
    Install Complete
    The installation of Peoplesoft Database Configuration is complete, but some
    errors occurred during the install.
       Please see the installation log for details.  Press "Done" to quit the
    installer.
    PRESS <ENTER> TO EXIT THE INSTALLER:
    [root@localhost PsMpDbInstall]#
    As you see the entire installation process above, the Installer cannot initialize Data Mover. I have run dbsetup.dms seperately, it cannot run. The 2 files psdmtx and parm1 cannot run.
    My questions are:
    First, how to get to Data Mover Bootstrap mode at this point of the installation so that import data into Database Instance ?
    Second, how to view Oracle database instances in Oracle Database Server so that make sure Database instance PT853 is created ?
    Thanks.

  • How do you compile JNI in Linux

    I do JNI well windows using command line facility from Visual Studio but i have never learnt compiling native code for Linux...

    A makefile would probably make the most sense. Here's the docs for the GNU make - http://www.delorie.com/gnu/docs/make/make_toc.html

  • "Exception in thread "main" java.lang.UnsatisfiedLinkError:"  JNI in Linux

    Hi,
    I am writing a simple program to understand how JNI works so that I can use this concept to develop a project. But after running the simple code,
    It gives the following error:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: sum
    at TestJni.main(testJni.java:25)
    My Java code is:
    import java.io.*;
    import java.util.*;
    class TestJni
    // Try to load the native Code library for user Authentication.
    static
    try
    System.loadLibrary( "test" );
    catch( UnsatisfiedLinkError e )
    System.out.println("Could not load native code for user authentication." );
    System.exit(1);
    public static void main( String [] args )
    //TestJni obj = new TestJni();
    System.out.println(TestJni.sum(2, 3));
    public static native int sum( int x, int y );
    TestJni.h looks like:
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class TestJni */
    #ifndef IncludedTestJni
    #define IncludedTestJni
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: TestJni
    * Method: sum
    * Signature: (II)I
    JNIEXPORT jint JNICALL Java_TestJni_sum
    (JNIEnv *, jclass, jint, jint);
    #ifdef __cplusplus
    #endif
    #endif
    and my C++ code is:
    #include <jni.h>
    #include "TestJni.h"
    #include <stdio.h>
    JNIEXPORT jint JNICALL Java_TestJni_sum(JNIEnv *env, jclass obj, jint x, jint y)
    printf("Inside the native function\n");
    return (x + y);
    Then I am generating my .so file as:
    g++ -o libtest.so sum.cpp -shared -fpic -lcrypt -I//usr/lib/j2se/1.4/include -I/usr/lib/j2se/1.4/include/linux
    and copying the libtest.so file into the folder where I have my TestJni.class file. Then running the java code by:
    java TestJni
    but it gives the "UnsatisfiedLinkError". What to do? :( I have spend 2 days now to solve this problem but I am not getting it.
    I am using ubuntu 7.10 as my OS.
    Please let me know if you can help.

    Thanks for your response. I found that, when I copied the shared library to /usr/lib and
    did: ldconfig -n /usr/lib it worked
    But the problem is, this is my computer, but the computers that I am going to run my actual
    JNI application, have restrictive permission. Could anyone please let me know how I can
    do the work without ldconfig. I mean is there anyway I can configure my .so file's path without
    copying it into the /usr/lib folder and without ldconfig?
    I will appreciate any reply. Thanks.

  • How to do JNI in Linux

    hi guys,
    i am new to Linux plotform
    i have some .so files writen in C++
    and i have the Java code. But how to call the methods in .SO file from Java thru JNI.
    thanx in advance.
    ---Subbu

    Subbu,
    Here's a link to a short tutorial on using JNI [ http://www.javaworld.com/javatips/jw-javatip141.html ]. I find working thru even a simple tutorial to be helpful. The other place is the following link [ http://java.sun.com/docs/books/jni/html/jniTOC.html ], although I'd work thru one or more tutorials before diving into the Sun docs.
    hth,
    adym

  • EDirectory users login issue(Linux Systems)

    Dear team,
    For PDC(primary domain controller)::
    We have installed SLES11-SP3 and OES11-SP2 on the top of this.
    After this, we configured DSFW and eDirectory.
    Now, when we are trying to login eDirectory users from Windows System,, we are able to do this.
    But when we trying from Linux Systems, users are able to login but not getting their respective directory (/home/user_name)
    For ADC(additional domain controller)::
    We configured same configuration as shown above by replicating tree.
    For this server, when we are trying to login eDirectory users from Windows and Linux Systems, we able to do this successfully without any issue.
    Both Servers we are using for high availability.
    Please help us on the PDC.
    Thanks

    Dear Team,
    As you asked we don't know whether it is using ncp or dsfw, please let us know this also. I want to give you clear picture, step by step.
    Goal:
    1. We have two systems, need replication of edirectory Partition.
    2. We need to login from edirectory users in windows/linux both
    3. We want to login into windows systems like AD users from DSFW, using domain login.
    4. We need to login in Linux machine with eDirectory users using LDAP authentication
    5. We need to sync both systems 24x7x365
    Implementation:
    1. We have install SLES11-S3 with OES2-S2 in first machine with image name OES11-SP2-addon_with_SLES11-SP3-x86_64-DVD.iso (4GB image size)
    https://www.novell.com/documentation.../b11i67vh.html
    a) Installation of forest root domain.
    b) New tree : K_TREE
    c) FDN : cn=administrator,cn=Users,dc=k2,dc=gov,dc=in
    d) Net bios domain name = k2
    e) Configure this server as WINS server:selected check box
    f) Site name : DC
    Particulars:
    IP : 10.0.0.136
    Hostname: PDC.k2.gov.in
    Domain: k2.gov.in
    Netbios name: k2
    NTP: 10.0.0.136 (we dont have ntp server as of now)
    Selected : Use multicast to access SLP
    Novell modular authentication services: Challenge response, NDS
    Then Novell OES configuration successfully done.
    2. In second server we have replicated first edirectory server.
    a) SLP Server : blank
    b) NTP: 10.0.0.136
    c) Existing tree : K_TREE
    d) IP:10.0.0.135
    e) FDN: cn=administrator,cn=Users,dc=k2,dc=gov,dc=in
    f) Enter Server Context: dc=k2,dc=gov,dc=.in
    g) Hostname : ADC.k2.gov.in
    We have installed only iManager and edirectory with existing PDC eDirectory.
    Replication done successfully
    IP Hostname Partition Windows without agent Linux LDAP replication home directory in linux
    PDC 10.0.0.136 PDC.k2.gov.in k2 login login done yes
    ADC 10.0.0.135 ADC.k2.gov.in k2 login login done no
    Testing PDC :
    1. Windows 7, successfully joined DSFW domain : k2.gov.in
    2. Windows Users are able to login from edirectory/DSFW users
    3. Linux Users are also able to login with normal shell, but not getting home directory
    Testing ADC :
    1. Windows 7, successfully joined DSFW domain : k2.gov.in
    2. Windows Users are able to login from edirectory/DSFW users
    3. Linux Users are also able to login with normal shell, also getting home directory
    Query : In PDC (DSFW Domain k2.gov.in) Linux users are getting shell but not getting Home directory in RHEL-6.5, but ADC (DSFW Domain k2.gov.in) Linux Users are getting shell as well as Home directory also.

  • JNI under Linux

    Hello everyone
    I am using linux 7.3 with jdk1.3. I have been successful writing and compiling a native method and hooking it up to JNI. I added the shared library file �.so� to /usr/lib/javalib
    directory then added library path into id.so.conf file under /etc directory.
    When I ran the test application I got that Exception. I guess it can't load the library. But I as mentioned above I already did added to use/lib/javalib folder and I did updated Id.so.conf file �.. am I missing something
    java TestparallePortJava
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no JavaParallePort in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1410)
    at java.lang.Runtime.loadLibrary0(Runtime.java:772)
    at java.lang.System.loadLibrary(System.java:832)
    at parallePortJava.<clinit>(parallePortJava.java:17)
    at TestparallePortJava.main(TestparallePortJava.java:11)
    Here is what I did if any one is interested in compiling and creating the shared library:
    g++ -c -I/usr/java/j2sdk1.4.0/include/ -I/usr/java/j2sdk1.4.0/include/linux parallePortJava.cc -o libJavaParallePort.o
    Then to create the shared library
    ld -shared -o libJavaParallePort.so libJavaParallePort.o

    I've just written a native library myself and found that the trick is to ensure that the envirnment variable LD_LIBRARY_PATH has been set correctly before my java program is invoked.
    In addition; if you are loading a native library from within Tomcat, you must ensure that LD_LIBRARY_PATH has been set before you start Tomcat.
    Oh, and by the way: Do not forget to "export" LD_LIBRARY_PATH. Here is a sample:
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/my/directory
    If your .so file also includes other .so files, I think you need to use the "-rpath" option when linking, i.e:
    ld -shared -soname=libmylib.so -rpath /path/to/other/libraries objectfiles

  • Calling an existing C code with JNI under linux.

    Hi all,
    I am trying to use an exsiting c code with jni but I am keep getting
    java.lang.UnsatisfiedLinkError, I am working under linux.
    This is what I have done so far:
    1.export LD_LIBRARY_PATH='pwd'/lib
    2. created HspellNative.java with the static System.loadLibrary("HspellNative") and native function called hspellInit
    3. compiled the java class
    4. javah -jni HspellNative
    5. HspellNative.c:
    #include <jni.h>
    #include <stdio.h>
    #include "HspellNative.h"
    #include "hspell.h"
    JNIEXPORT jint JNICALL
    Java_HspellNative_hspellInit ( JNIEnv* env, jobject obj )
         struct dict_radix **dict;
         return ( (jint) (hspell_init(dict,0) ) );
    6. could be the problematic one:
    gcc -o lib/libHspellNative.so -shared -I/opt/bea/jdk142_05/include -I/opt/bea/jdk142_05/include/linux hspell.c HspellNative.c
    7. java HspellNative
    8. getting the following error:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/haim/Hspell/hspell-0.9/lib/libHspellNative.so: /opt/haim/Hspell/hspell-0.9/lib/libHspellNative.so: undefined symbol: hspell_debug
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1511)
    at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    at java.lang.System.loadLibrary(System.java:834)
    at HspellNative.<clinit>(HspellNative.java:18)
    My problem is that I don't know how to combine my HspellNative.c to the existing hspell.c, I know I should put them together in the shared library somehow, but how ?
    Please advice.
    Thanks in advance,
    Haim.

    I know there is something wrong with the .so, the question is: what ? and how do I fix it ?
    This is the ldd ldd libHspellNative.so output:
    /etc/libcwait.so => /etc/libcwait.so (0x0060b000)
    libc.so.6 => /lib/tls/libc.so.6 (0x00111000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00359000)
    I have no idea what it means...
    I think I will try the SWIG.
    Thanks any way.

  • Query regarding using JNI in linux

    Hi
    I have a query regarding JNI.We have a situation in which
    we have some c programmes and we want to call that c programme method in my java code. The problem is that in JNI the native code signature should match the signature of the method of the header file generated by javah. We donot want to change the signature of the native code since it is hard to debug.So please suggest me a way out that i can call the native method without changing the signature of the native code.Please if u could give me some few simple example
    Thanking u

    So please suggest me a way out that i can call the native method without changing the signature of the native code.You write a wrapper. Your java JNI class has methods. Those methods are written in C by you. Those methods are new code. Those methods call your existing C methods.
    Please if u could give me some few simple example.http://java.sun.com/docs/books/tutorial/native1.1/index.html

  • How do run the jni in linux enviroment??

    I run the HelloWorld sample in linux
    but I stock in load the share library!
    When I type this command as following:
    cc -G -I/usr/local/java/include -I/usr/local/java/include/linux \
    HelloWorldImp.c -o libhello.so
    there are error message like this :
    unrecognized option '-G'
    /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o:In function '_start':
    /usr/lib/gcc-lib/i386-redhat-linux/2.96/../../../crt1.o(.text+0x18):
    undefined reference to 'main'
    can you help me solve the problem?

    gcc -I/usr/lib/java-1.3/include -I/usr/lib/java-1.3/include/linux \
         -fPIC -g -c -Wall HelloWorldImp.c
    gcc -shared -Wl,-soname,libhello.so -o libhello.so HelloWorldImp.o
    when you call the library in java
    System.loadLibrary("hello");

  • Solaris - Windows JNI Issues

    *** Setting the scene ***
    I am trying to write a library called GuidGetPid which will have only 1 method to return the current pid.
    The header file generated by javah only has the following declaration in it:
    * Class:     GuidGenerator
    * Method:    getPid
    * Signature: ()I
    JNIEXPORT jint JNICALL Java_GuidGenerator_getPid
      (JNIEnv *, jclass);I am new to working with JNI, but I was succussful in implementing and running my program in Solaris.
    The implementation in C is:
    #include <unistd.h>
    #include <jni.h>
    #include "GuidGenerator.h"
    JNIEXPORT jint JNICALL
    Java_GuidGenerator_getPid(JNIEnv *env, jobject obj)
         return getpid();
    }*** My problem ***
    I am trying to implement this is WinXP now. In MS VC 6.0, I wrote the following cpp file.
    #include <process.h>
    #include <jni.h>
    #include "GuidGenerator.h"
    JNIEXPORT jint JNICALL
    Java_GuidGenerator_getPid(JNIEnv *env, jobject obj)
         return getpid();
    }Everything will compile, and java can find the library, but for some reason it cannot locate the method getPid. Specifically I get the error message
    Exception in thread "main" java.lang.UnsatisfiedLinkError: getPid
            at com.ml.mlim.mlde.pls.GuidGenerator.getPid(Native Method)
            at com.ml.mlim.mlde.pls.GuidGenerator.nextID(GuidGenerator.java:49)
            at com.ml.mlim.mlde.pls.tester.main(tester.java:23)Does anyone have any suggestions as to how I can fix this?

    Hmm... strangely (maybe not), it works for me. Here, I've posted everything I used, including the generated header file and the command line arguments I used.
    ****** Java source file ******
    public class test
         public static native int getPid ();
         static
              System.loadLibrary ("test");
         public static void main (String [] args)
              System.out.println (getPid ());
    }*******Generated header file********
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class test */
    #ifndef _Included_test
    #define _Included_test
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class:     test
    * Method:    getPid
    * Signature: ()I
    JNIEXPORT jint JNICALL Java_test_getPid
      (JNIEnv *, jclass);
    #ifdef __cplusplus
    #endif
    #endif******** C source file ********
    #include <jni.h>
    #include <process.h>
    #include "test.h"
    JNIEXPORT jint JNICALL Java_test_getPid (JNIEnv *env, jclass cls)
         return (jint) getpid ();
    }******* Command line arguments *******
    cl -Ic:\j2sdk1.4.2\include -Ic:\j2sdk1.4.2\include\win32 test.c -LD -Fetest.dll
    Hope any of that information helped.
    If you still have problems, check if the dll is anywhere on your system (or rename it completely so that there will be no conflicts whatsoever).
    Cheers.

  • Issuing Linux commands from within C++ in XCode

    Friends:
    I understand C++ and Linux on OS X are very united. I'm using C++ inside XCode.
    Can you post a small C++ program which, say runs the list function ls?
    I'd like to see how it is done.
    Thanks, -Migs

    The output was this, not quite the unix like directory listing I expected (a listing of the directory):
    (I do remain grateful for your input though !!!!!! -Migs)
    [Session started at 2008-11-19 11:14:47 -0400.]
    DoWhileLoop fibonacci
    DoWhileLoop.dSYM fibonacci.dSYM
    ForLoop for_loop
    ForLoop.dSYM for_loop.dSYM
    HelloWorld functionall_inparams
    HelloWorld.dSYM functionall_inparams.dSYM
    If functionreturnsnumber
    If.dSYM functionreturnsnumber.dSYM
    LinearConguential_Rand_NumGen function_simple
    LinearConguential_Rand_NumGen.dSYM function_simple.dSYM
    ListingToLinux functionsimple2
    ListingToLinux.dSYM functionsimple2.dSYM
    OutOfMemory hello
    OutOfMemory.dSYM hello.dSYM
    Printing kevinsexample
    Printing.dSYM kevinsexample.dSYM
    count2 lpt1
    count2.dSYM random_numbers
    decreasingforloop random_numbers.dSYM
    decreasingforloop.dSYM while_loop
    dowhileloop while_loop.dSYM
    dowhileloop.dSYM
    The Debugger has exited with status 0.

  • JNI Issue on JDK vs JRE

    Dear all,
    I've a JNI dll that run fine when the execution is done with java.exe of JDK, but if I execute the code using java.exe of JRE I got an error of "access an invalid memory location". Both JDK and JRE are "1.6.0_21" on 32 bits.
    Does anybody already have a problem like this?
    Best regards

    You have a bug in your JNI code. Pointer error or a misuse of an API.
    The fact that it works in one place does not change that. It only means that the failure didn't cause that one to fail.

Maybe you are looking for