0

I am working on a programm which reads the data from a barcodescanner. To connect with the scanner, i use usb4java which works great.

After i finished my programm i wanted to test in on another computer. The result is a LoaderException from usb4java "Native library not found in classpath: /org/usb4java/windows-x86_64/libusb-1.0.dll".

I have searched on google and stackoverflow and found different a lot of answers about MANIFEST.MF, getResource() and getResourceAsStream() but nothing helped. It never worked on the other computer. So i looked in the class from usb4java which throws the exception line 277: https://github.com/usb4java/usb4java/blob/master/src/main/java/org/usb4java/Loader.java So i thought i just add following line to my program code:

System.out.println(Loader.class.getResource("/org/usb4java/windows-x86_64/libusb-1.0.dll"));

The result on my computer shows the directory is found:

jar:file:/C:/Users/somename/Desktop/scanner/BarcodeScanner.jar!/org/usb/windows-x86_64/libusb-1.0.dll

The result on the other computer is just:

null

This indicates the problem is not in the program code.

I searched a lot of hours but I am not able to find out the problem.

Here a screenshot of the exception: LoaderException

Edit: I forgot to mention the jar-files: here is a picture from my project in eclipse: enter image description here

Edit2: unzipped jar file

content of MANIFEST.MF from directory META-INF: MANIFEST.MF

mavok
  • 27
  • 14
  • Are you running the same jar file in both computers? In your example the output is /C:/Users/somename/Desktop/scanner/ **BarcodeScanner.jar** !/org/usb/windows-x86_64/libusb-1.0.dll but in the picture you are executing java -jar **BarcodeScannerProgramTest.jar** – Marco A. Hernandez Aug 09 '16 at 09:14
  • The example from the output on my computer ist just "BarcodeScanner.jar" because i run the project in eclipse. The example with the console "BarcodeScannerProgramTest.jar" is from the other computer with an exorted jar file. When i run the same jar file on my computer i have no problems. – mavok Aug 09 '16 at 09:27
  • Eclipse uses different classloader than the exported jar file. Are you absolutely sure that java -jar BarcodeScannerProgramTest.jar runs in your computer? In other words, are you absolutely sure that the folder org/usb4java/windows-x86_64 exists in the root of this jar file? – Marco A. Hernandez Aug 09 '16 at 09:37
  • Yes, i am absolutely sure. When i use 7zip to unpack (not sure if it is the right word) the jar file, i see the directory org with a directory usb4java in with etc. – mavok Aug 09 '16 at 09:41
  • To be absolutely sure i exported a new jar file from eclipse and run it on both computers with the same results. The files in the project is as in the last picture, so the dll's are really in the jar file. – mavok Aug 09 '16 at 10:38
  • Can you post a picture of the unzipped BarcodeScannerProgramTest.jar and the content of MANIFEST.MF? – Marco A. Hernandez Aug 09 '16 at 11:40
  • Everything looks on its place... Are the two computers 64bits Windows? Maybe you could try exporting the Runnable JAR FIle checking "Package required libs" instead of "Extract required libs" at Library handlings. Sadly I can't see the reason of the error. – Marco A. Hernandez Aug 09 '16 at 12:13
  • Thank you very much! Know it runs on the other computer too. Do you have an explanation for this 'weird' behaviour? – mavok Aug 09 '16 at 12:43

0 Answers0