Wishing you all a Happy and Prosperous New Year 2009


Nov 6, 2008

jsr080 - javax.usb - A Java based USB Library

1. JSR-080 Introduction

JSR-080 (JSR080 or JSR-80) is a Java Specification Request in the Java Community Process(SM) Program. The JSR080 specification provides a standard Java(TM) API for communicating with any device attached to the computer via Universal Serial Bus (USB). It allows Java applications to discover, read, write, and manage USB devices.
The JSR080 specification is released during year 2005. More details about the JSR080(JSR-80) can be found here.

2. javax.usb Introduction

javax.usb is an Opensource implementaion for the API provided in JSR080. There are 7 modules in javax.usb project. They are listed below.
  • javax-usb: The actual API implementation as per JSR080.
  • javax-usb-ri: This is the common RI (Partial OS-Independent Reference Implementation ).
  • javax-usb-ri-linux: This is the Linux implementation that connects the Linux USB Stack to OS-Independent RI.
  • javax-usb-ri-windows: This is an ABANDONED Windows implementation. it does not work, it needs a kernel driver.
  • javax-usb-libusb: This is an alpha libusb implementation (written for Windows).
  • javax-usb-tck: This is the Test Compliance Kit (TCK) required by the JCP.
  • javax-usb-example: This package contains example code that shows how the API can be used.
There is also a BSD implementation created by Ricoh. For more information, visit either their global site and register for the Ricoh Developer Program (RiDP).
3. How javax.usb API looks?

The starting point to use the API is a Java class USBHostManager. This class lets you obtain an OS-specific instance of the USBServices interface (based on information in javax.usb.properties), from which you can obtain the virtual root hub:
UsbServices services =
UsbHostManager.getUsbServices ();
UsbHub vroothub = services.getRootUsbHub ();


The virtual root hub, obtained by calling UsbServices's public UsbHub getRootUsbHub() method, provides access to all of the available host controllers (and their root hubs). UsbHub's public boolean isRootUsbHub(), public byte getNumberOfPorts(), and public List getUsbPorts() methods are useful in verifying, enumerating, and obtaining root hubs.

More details on how to access USB devices is explained here: "Access USB Devices from Java Applications"

No comments: