0

I am trying to load libhydro.dll using java native access.I kept the LibHydro.dll which is a 32 bit in C:\Windows\SysWOW64 My system is a 64 **bit windows 10 machine.I tried to register the dll but i am getting error as

Make sure the library is stored at the specified path or debug it to check for problems with the binary or dependent dll files.The specified module could not be run.

When i try to run my program it is throwing error as

C:\JNI_project>javac New.java

C:\JNI_project>java New
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'LibHydro': The specified module could not be found.

        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
        at com.sun.jna.Library$Handler.<init>(Library.java:140)
        at com.sun.jna.Native.loadLibrary(Native.java:379)
        at com.sun.jna.Native.loadLibrary(Native.java:364)
        at New.main(New.java:10)

My program is

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

/** Simple example of Windows native library declaration and usage. */
public class New{
   public interface LibHydro extends Library {

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

   }
}

please guide me.

johnson
  • 117
  • 3
  • 12
  • See if this helps, http://stackoverflow.com/questions/14286647/trying-to-use-dll-from-java-jna-unable-to-load-library-exception – Adisesha Oct 30 '15 at 05:49

2 Answers2

0

You must use a 32-bit JRE if your library is 32-bit. This is a restriction imposed by the WoW64 system (the link says, in part, 32-bit applications ... that plug into the process space of components that are implemented purely as 64-bit processes (e.g. Windows Explorer) cannot be executed on a 64-bit platform). The 64-bit JRE is purely a 64-bit process.

Addintionally, your library should be on the PATH for Windows (on Unix like systems you can use LD_LIBRARY_PATH), or you can use a script and something like -Djava.library.path=/somewhere on both.

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
  • In libhydro site it is written as ::- NOTE: This DLL must be located in c:\temp\MBlibHydro in order for MBlibHydro.dll to locate it. The location can be changed by altering the function path names in mLibHydro.bas in the source code of MBlibHydro.DLL. does it mean i have to get MBlibhydro.dll and store it in some folder in my system for the working of LibHydro.dll – johnson Oct 30 '15 at 06:00
  • In libhydro site it is written as ::- NOTE: This DLL must be located in c:\temp\MBlibHydro in order for MBlibHydro.dll to locate it. The location can be changed by altering the function path names in mLibHydro.bas in the source code of MBlibHydro.DLL. does it mean i have to get MBlibhydro.dll and store it in some folder in my system for the working of LibHydro.dll – johnson Oct 30 '15 at 06:41
  • Is `MBlibHydro.DLL` an additional DLL that needs loading? – technomage Oct 30 '15 at 18:37
0

You need to tell JNA where to load the library. JNA can usually find it if it's on PATH, but for libraries intended to be loaded by JNA directly you should set the system property jna.library.path to include all paths to your DLLs.

technomage
  • 9,861
  • 2
  • 26
  • 40