1

I know that I have to store my libraries into java.library.path folders. I put my dll insite c:\windows\system32 folder (I'm using 32bit jre) and I tried this code:

public static void main(String[] args) {
    System.out.println(System.getProperty("java.library.path"));
    System.loadLibrary("ZebraNativeUsbAdapter_32");
}

And I got this output:

C:\Program Files (x86)\Java\jre1.8.0_73\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;D:\Programmi\Skype\Phone\;C:\Program Files\SourceGear\Common\DiffMerge\;C:\Program Files\MariaDB 10.1\bin;.

And this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no ZebraNativeUsbAdapter_32 in java.library.path

Then I tried to put dll file into C:\Program Files (x86)\Java\jre1.8.0_73\bin and it works! But why both folder were listed in java.library.path but only one of these works?

JoshDM
  • 4,939
  • 7
  • 43
  • 72
Tobia
  • 9,165
  • 28
  • 114
  • 219
  • 4
    For the *worst joke* contest: "Java finds native libraries adorable". :) – Costi Ciudatu Sep 18 '16 at 14:27
  • 1
    As you can see from the dup. link, the `system32` folder is weird. It is only used for 64-bit DLLs, and 32-bit programs will load from `syswow64`, regardless of what the `PATH` says. My recommendation: Never put custom/3rd-party DLLs in `system32`. Leave that folder for "system" DLLs. – Andreas Sep 18 '16 at 14:31

0 Answers0