1 Reply Latest reply: Oct 2, 2012 12:55 PM by 965117 RSS

    How to JSR80 on Linux

    965117
      Hi everyone, i am new to Java, currently i am trying to get USB device info using JSR80 API. for this I have added all required jar files. but i am getting following error how to resolve?. I am using eclipse on Fedora17 with opendjk-1.7.0_07

      Exception in thread "main" java.lang.UnsatisfiedLinkError: com.ibm.jusb.os.linux.JavaxUsb.nativeSetTraceOutput(ILjava/lang/String;)V
           at com.ibm.jusb.os.linux.JavaxUsb.nativeSetTraceOutput(Native Method)
           at com.ibm.jusb.os.linux.LinuxUsbServices.checkProperties(LinuxUsbServices.java:95)
           at com.ibm.jusb.os.linux.LinuxUsbServices.<init>(LinuxUsbServices.java:34)
           at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
           at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
           at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
           at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
           at java.lang.Class.newInstance0(Class.java:372)
           at java.lang.Class.newInstance(Class.java:325)
           at javax.usb.UsbHostManager.createUsbServices(Unknown Source)
           at javax.usb.UsbHostManager.getUsbServices(Unknown Source)
           at usb.TraverseUSB.main(TraverseUSB.java:22)


      My Java code

      import java.io.UnsupportedEncodingException;
      import java.util.List;

      import javax.usb.UsbDevice;
      import javax.usb.UsbDisconnectedException;
      import javax.usb.UsbException;
      import javax.usb.UsbHostManager;
      import javax.usb.UsbHub;
      import javax.usb.UsbServices;

      public class TraverseUSB {

           @SuppressWarnings("rawtypes")
           static List attachedDevices;

           public static void main(String[] args)
           {          
                try
      {
                     
           System.load("/home/Agile/Java/ExtJar/libJavaxUsb.so");          
      UsbServices services = UsbHostManager.getUsbServices();
      UsbHub rootHub = services.getRootUsbHub();
      traverse(rootHub);

      } catch (Exception e) {
           
           e.printStackTrace();
      }
      }

      public static void traverse(UsbDevice device)
      {
           if (device.isUsbHub())
           {  
                // This is a USB Hub, traverse through the hub.
                attachedDevices = ((UsbHub) device).getAttachedUsbDevices();          
                for (int i=0; i<attachedDevices.size(); i++)
                {
                traverse((UsbDevice) attachedDevices.get(i));     
                try {
                                    System.out.println(device.getSerialNumberString());
                               } catch (UnsupportedEncodingException | UsbDisconnectedException | UsbException e) {
                                    
                                    e.printStackTrace();
                               }
                }
           }
           
           else
           {
                     
           }
      }
                
      }