Forum Stats

  • 3,826,759 Users
  • 2,260,705 Discussions
  • 7,897,072 Comments

Discussions

Java Native Access

Gage-Bollo
Gage-Bollo Member Posts: 25
edited Dec 5, 2013 4:45PM in Java Native Interface (JNI)

Hi

I would like the help in finding the root of my dll error. I have a dll, that when viewed in DLL Export Viewer, has this function signature "enum Artec::BroadwaySoftware::RcpClient::RESULT __stdcall Artec::BroadwaySoftware::RcpClient::checkServer(char const *)". I do not understand why this function (all functions in this dll) shows it the way it does. I can confirm that the dll loads just fine but I then receive a "Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'checkServer': The specified procedure could not be found." exception. Can someone tell me why that is?

<code>

package artec.broadway.application;

import com.sun.jna.Library;

import com.sun.jna.Native;

import java.util.Vector;

import java.util.logging.Level;

import java.util.logging.Logger;

import sdk.exceptions.BSSException;

/**

*

* @author Zweli

*/

public class ArtecBroadwayApplication {  

    public static void main(String[] args) {

        String id = "192.168.1.224:8080";

        try {

            System.out.println("response: " + new BSSRPCClient().getVersion(id));

            System.out.println("version: " + id);

        } catch (BSSException e) {}

      

    }  

}

class BSSRPCClient {

    public static final String DLL_NAME = "bssrpc_client";   

    private final C_BSSRPC_DLL lib;

  

    public BSSRPCClient() {

        System.loadLibrary(DLL_NAME);

        lib = (C_BSSRPC_DLL)Native.loadLibrary(DLL_NAME, C_BSSRPC_DLL.class);

      

        //lists loaded dll files

        for (String library : ClassScope.getLoadedLibraries(ClassLoader.getSystemClassLoader())) {

            System.out.println(library);

        }

    }

  

    public String getVersion(String server) throws BSSException  {

        return lib.checkServer(server) + "";

    } 

}

class ClassScope {

    private static java.lang.reflect.Field LIBRARIES;

    static {

        try {

            LIBRARIES = ClassLoader.class.getDeclaredField("loadedLibraryNames");

            LIBRARIES.setAccessible(true);

        } catch (NoSuchFieldException | SecurityException ex) {

            Logger.getLogger(ClassScope.class.getName()).log(Level.SEVERE, null, ex);

        }

    }

    public static String[] getLoadedLibraries(final ClassLoader loader) {

        Vector<String> libraries = null;

        try {

            libraries = (Vector<String>) LIBRARIES.get(loader);

        } catch (IllegalArgumentException | IllegalAccessException ex) {

            Logger.getLogger(ClassScope.class.getName()).log(Level.SEVERE, null, ex);

        }

        return libraries.toArray(new String[] {});

    }

}

interface C_BSSRPC_DLL extends Library {

    int checkServer(String server) throws BSSException;

}

</code>

Regards

Zweli

Answers

This discussion has been closed.