Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Java Native Access

Gage-BolloDec 2 2013 — edited Dec 5 2013

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

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 2 2014
Added on Dec 2 2013
1 comment
3,479 views