java.lang.NoClassDefFoundError: org/usb4java/Loader

365 views
Skip to first unread message

JC

unread,
Feb 19, 2020, 6:49:33 PM2/19/20
to usb4java
Fairly new to Java here and I'm trying to create a project in Java that uses USB devices. I think I have covered all the dependencies as the example DumpDeviceTree doesn't give me any errors in NetBeans. However, when I try to run the program I get the following errors:

Exception in thread "main" java.lang.NoClassDefFoundError: org/usb4java/Loader
    at org.usb4java.javax.Services.<init>(Services.java:59)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at javax.usb.UsbHostManager.createUsbServices(Unknown Source)
    at javax.usb.UsbHostManager.getUsbServices(Unknown Source)
    at DumpDeviceTree.main(DumpDeviceTree.java:43)
Caused by: java.lang.ClassNotFoundException: org.usb4java.Loader
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 9 more
Java Result: 1


As I am new to usb4java, I don't have a clue what this all means. If someone could provide some hints I would appreciate it. Thanks.

JC

JC

unread,
Feb 19, 2020, 6:58:35 PM2/19/20
to usb4java
Ok got that part figured out. I mistakenly removed the usb4java jar from the libraries. I am now getting this error:

Exception in thread "main" org.usb4java.LoaderException: Native library not found in classpath: /org/usb4java/win32-x86-64/libusb4java.dll
    at org.usb4java.Loader.extractLibrary(Loader.java:246)
    at org.usb4java.Loader.load(Loader.java:323)

    at org.usb4java.javax.Services.<init>(Services.java:59)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at javax.usb.UsbHostManager.createUsbServices(Unknown Source)
    at javax.usb.UsbHostManager.getUsbServices(Unknown Source)
    at DumpDeviceTree.main(DumpDeviceTree.java:43)
Java Result: 1

JC

unread,
Feb 19, 2020, 7:09:18 PM2/19/20
to usb4java
Beautiful, got it working! I think I was reading too much. Got confused by the github page where it states:

This is the source code of the JNI wrapper for libusb. usb4java already includes prebuilt libraries for the following platforms:

Got stuck on "already includes".

I ended up downloading the jar org/usb4java/libusb4java/1.3.0 from a maven repo and it works fine now.




On Wednesday, February 19, 2020 at 6:49:33 PM UTC-5, JC wrote:
Reply all
Reply to author
Forward
0 new messages