Hi there,
Is it possible to write a Java application to call Win32.DLL in Linux
Environment?
Below are my first attempt based on getting started section at JNA website:
public interface Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = (Kernel32) Native.loadLibrary("kernel32",
Kernel32.class);
public static class SYSTEMTIME extends Structure {
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliSeconds;
}
void GetSystemTime(SYSTEMTIME systemtime);
}
public static void main(String[] args) {
Kernel32 kernel32 = Kernel32.INSTANCE;
SYSTEMTIME systemtime = new SYSTEMTIME();
kernel32.GetSystemTime(systemtime);
System.out.println("Today Integer value is: " + systemtime.wDay);
}
I got myself error below:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load
library 'kernel32': libkernel32.so: cannot open shared object file: No such
file or directory
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:114)
I had place the kernel32.dll inside the classpath of the project.
Please advise.
Thank you,
David