Skip to main content

Doesn't found the method inside dll (JNA)

No replies
mvelosus
Offline
Joined: 2012-09-25
Points: 0

Hi,
I have a dll called "EnigmaEncriptacionwith.dll" with the following structure.

namespace EnigmaEncriptacion
{
    public static class Encriptador
    {
        // Nested Types
        public static class Jan7Encriptador
        {
            // Methods
             public static string Encriptar(string textoQueEncriptaremos, string key);

        }
    }
}

But I can not call the method Encriptar, inside DLL. Here is my java code.

import com.sun.jna.Library;
import com.sun.jna.Native;

public class CallDLLMethod {

public interface EnigmaEncriptacion extends Library {
    public String Encriptar(String a, String b);
    }

public static void main(String[] args) {
EnigmaEncriptacion lib = (EnigmaEncriptacion) Native.loadLibrary("EnigmaEncriptacion", EnigmaEncriptacion.class);
        lib.Encriptar("a", "b");
}
}

The exception thrown

Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'Encriptar': The specified procedure could not be found.
at com.sun.jna.Function.(Function.java:179)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:344)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:324)
at com.sun.jna.Library$Handler.invoke(Library.java:203)
at $Proxy0.Encriptar(Unknown Source)
at CallDLLMethod.main(CallDLLMethod.java:12)

I think this is the structure of the DLL, the method Encrypt (String, String) is not within the class Encriptador, is within the class Jan7Encriptador which is within the class Encriptador.

I searched on the subject but found nothing about it, can anyone help?

Thanks ^^