Importing DLL into Eclipse Java project

19,382

Solution 1

Don't put ".dll" at the end of your library. That is a Windows-specific extension, and your call will work on other systems with other extensions, so putting the extension on is incorrect. Just load "myAPI" and, if that's the right names and other things are as advertised, it will work.

Solution 2

One option is to try keeping that dll in your /jre/bin used in eclipse system library and was able to configure dll files at runtime , by placing dll in /jre/bin

It is the simplest way i could find out. This work for me.Hopefully will help you.:)

Share:
19,382
Klausos Klausos
Author by

Klausos Klausos

Updated on June 05, 2022

Comments

  • Klausos Klausos
    Klausos Klausos almost 2 years

    To import DLL into Eclipse Java project, I checked the "java.library.path"

    String path = System.getProperty("java.library.path");
    System.out.println(path);
    

    One of the path values was equal to C:/Windows/System32. Therefore I saved myAPI.dll in C:/Windows/System32. Then I called System.loadLibrary:

    System.loadLibrary("myAPI.dll");
    

    And got the error message:

    Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Expecting an absolute path of the library: myAPI.dll
        at java.lang.Runtime.load0(Unknown Source)
        at java.lang.System.load(Unknown Source)
    

    BTW, I tried to put my DLL file in different other directories that was mentioned in path. But each time I got the same error message. How to solve this problem?