1 Reply Latest reply: Aug 10, 2011 12:52 PM by 798692 RSS

    Accessing methods in linux .so file

    881629
      Hi,

      I have been given a .so file from a third party that is developed in C++. The file is named convertor.so


      If i run
      objdump -tT convertor.so 
      I get the following where the method I need to invoke in Java is named ConvertSingle, it is listed in the dynamic symbol table rather than the symbol table
      convertor.so.so:     file format elf32-i386
      SYMBOL TABLE:
      no symbols
      DYNAMIC SYMBOL TABLE:
      0000af40 g    DF .text     0000034a  Base        ConvertSingle 
      I have created a Java class as follows;
      public class ConvertClass{
      
              static{
                System.loadLibrary("convertor");
              }
              private native int  ConvertSingle(byte[] byteArray);
      
              public static void main(String args[]){
      
                  ConvertClass myClass = new ConvertClass():
                }
               } 
      But if I try to invoke my compiled class using java ConvertClass, I am constantly getting the error below;

      exception in thread "main" java.lang.UnsatisfiedLinkError: no convertor in java.library.path
           at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1738)
           at java.lang.Runtime.loadLibrary0(Runtime.java:823)
           at java.lang.System.loadLibrary(System.java:1028)
           at ConvertClass.<clinit>(ConvertClass.java:5)
      Could not find the main class: ConvertClass.  Program will exit.
       
      I have set the ld_libray_path
      LD_LIBRARY_PATH=.
      export LIBRARY_PATH
      ldconfig.
       
      Could anyone help as to what I might be doing wrong?

      Any help would be very much appreciated.

      many thanks.
      DM

      Edited by: user5780461 on Aug 10, 2011 10:54 AM
        • 1. Re: Accessing methods in linux .so file
          798692
          Edit your post. Post the codes inside the
           tag.
          
          Read this link to format your code to make easier for those who reads your post to help.
          
          [url]http://wikis.sun.com/display/Forums/Forums+FAQ[/url]