Unable to load library 'win64': Native library (win32-x86-64/win64.dll) not found in resource path

5,153 views
Skip to first unread message

Vishwajit

unread,
May 2, 2017, 10:01:48 AM5/2/17
to Java Native Access
Hi Guys,

I am getting below Exception while accessing Windows 7 Native library.

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'win64': Native library (win32-x86-64/win64.dll) not found in resource path ([file:/C:/Users/o2petp/workspace/Practice/bin/, file:/C:/Users/o2petp/workspace/Practice/lib/gson-2.7.jar, file:/C:/Users/o2petp/workspace/Practice/lib/jna-platform-4.4.0.jar, file:/C:/Users/o2petp/workspace/Practice/lib/jna-4.4.0.jar])
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:303)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:427)
at com.sun.jna.Library$Handler.<init>(Library.java:179)
at com.sun.jna.Native.loadLibrary(Native.java:569)
at download.wallpaper.WallpaperDownloader$User32.<clinit>(WallpaperDownloader.java:47)
at download.wallpaper.WallpaperDownloader.main(WallpaperDownloader.java:43)

Now, I am unable to find a library path of win32-x86-64/win64.dll. Where it is located and whats a path?


Thank you,
Vishwajit

Matthias Bläsing

unread,
May 2, 2017, 12:31:43 PM5/2/17
to jna-...@googlegroups.com
Hey,
show your code around WallpaperDownloader.java:47 I'd bet, that you try
to load a library that does not exist.

Greetings

Matthias

Vishwajit

unread,
May 3, 2017, 1:20:48 AM5/3/17
to Java Native Access
Hello,

Below are my code lines:


line 46           public static interface User32 extends Library{
line 47              User32 INSTANCE = (User32) Native.loadLibrary("win64", User32.class, W32APIOptions.DEFAULT_OPTIONS);
line 48         boolean SystemParametersInfo(int one, int two, String s, int three);
line 49    } 



Thank you,
Vishwajit

Matthias Bläsing

unread,
May 3, 2017, 1:17:22 PM5/3/17
to jna-...@googlegroups.com
Hey,

Am Dienstag, den 02.05.2017, 22:20 -0700 schrieb Vishwajit:
> On Tuesday, May 2, 2017 at 10:01:43 PM UTC+5:30, Matthias Bläsing wrote:
> > Am Dienstag, den 02.05.2017, 07:01 -0700 schrieb Vishwajit: 
> > > I am getting below Exception while accessing Windows 7 Native
> > library. 
> > > 
> > > Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'win64': Native library (win32-x86-64/win64.dll) not found in resource path ([file:/C:/Users/o2petp/workspace/Practice/bin/, file:/C:/Users/o2petp/workspace/Practice/lib/gson-2.7.jar, file:/C:/Users/o2petp/workspace/Practice/lib/jna-platform-4.4.0.jar, file:/C:/Users/o2petp/workspace/Practice/lib/jna-4.4.0.jar]) 
> > >         at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:303) 
> > >         at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:427) 
> > >         at com.sun.jna.Library$Handler.<init>(Library.java:179) 
> > >         at com.sun.jna.Native.loadLibrary(Native.java:569) 
> > >         at download.wallpaper.WallpaperDownloader$User32.<clinit>(WallpaperDownloader.java:47) 
> > >         at download.wallpaper.WallpaperDownloader.main(WallpaperDownloader.java:43) 
>
>
> > > line 47              User32 INSTANCE = (User32) Native.loadLibrary("win64", User32.class, W32APIOptions.DEFAULT_OPTIONS);


You are calling this Variant of the loadLibrary function:

    public static <T> T loadLibrary(String name, Class<T> interfaceClass, Map<String, ?> options) {

From the documentation:

     * @param name Library base name
     * @param interfaceClass The implementation wrapper interface
     * @param options Map of library options

So you ask JNA to load a library with the name "win64" by definition
this means on windows the library must reside in win64.dll and that
can't be found.

According to:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724947(v=vs.85).aspx
the function

SystemParametersInfo

resides in:

DLL: User32.dll

So you want:

User32 INSTANCE = Native.loadLibrary("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS);

Greetings

Matthias
Reply all
Reply to author
Forward
0 new messages