Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i tried to import dll using system.load().but it showing an exception of java.lang.UnsatisfiedLinkError: led_data_send.SendColorTp(IIIILjava/lang/String;IIII)I.
i kept dll in d drive.so i specified the path of dll to d://LEDBAR.dll
i am calling a function SendColorTp in dll.

code as shown below

Java
private native int SendColorTp(int Port, int Addr, int Mode, int Delay, String Context, int FontSize, int FontColor, int SignWidth, int SignHeight);

static{
    System.load("D:\\LEDBAR.dll");
}
Posted
Updated 23-Jul-13 1:10am
v3
Comments
Shubhashish_Mandal 23-Jul-13 8:02am    
I guess that the dll is loaded successfully otherwise you will get the following error
"java.lang.UnsatisfiedLinkError: Unable to load library ". So check the method you called is present in the dll or not
pasztorpisti 23-Jul-13 15:37pm    
You are probably right. Using the javah tool would help to avoid bad implementation signatures.

1 solution

First compile your java source into a class file (inside your ide or with javac). Then run the javah program on the class file. This javah program will generate the function declarations into a C/C++ header file. Use this header to implement/export the functions in your DLL.
Example:

_package/X.java:
Java
package _package;

public class X
{
    public native int func(float f, boolean b);

    public static void main(String[] args)
    {
        System.out.println("Hello World!");
    }
}


We run the following commands outside the _package directory:
javac _package/*.java
javah _package.X

After running these commands you will find a _package_X.h file in the current dir.
 
Share this answer
 
Comments
harishhn 24-Jul-13 7:48am    
i have done according to you but it showing same exception as like previous..
pasztorpisti 24-Jul-13 8:16am    
Get a tool that can list the name of exported symbols of your DLL and check the DLL.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900