2 messages in net.java.dev.jna.usersNewbie Question: Calling Win32.DLL in...
FromSent OnAttachments
d^v1dv00Jan 14, 2008 8:35 pm 
Timothy WallJan 15, 2008 5:35 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Newbie Question: Calling Win32.DLL in Linux EnvironmentActions...
From:d^v1dv00 (davi@gmail.com)
Date:Jan 14, 2008 8:35:42 pm
List:net.java.dev.jna.users

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