4

i am new for java. I need help to detect the USB event whenever user will plug-in to USB port.This should be worked out for linux O.S. using java.Please suggest me api which can full fill my requirements

thanks in advance :)

Prashant
  • 1,351
  • 3
  • 20
  • 32

2 Answers2

1

You can use this:

http://jusb.sourceforge.net/

Check this discussion also:

SWT: Getting notified of a system device change (USB device connection / disconnection)

Edit1. Bare in mind that jusb is discontinued. However, it's complete source code is available on sf.

Community
  • 1
  • 1
Sterpu Mihai
  • 486
  • 1
  • 4
  • 15
  • Hi Sterpu, scenario is like, i am having USB hub which has multiple USB ports. when i will plugin device to port, java code should be able to recognize hardware interrupt.It should be worked when user will attach usb devices. – Prashant Nov 19 '12 at 09:34
  • Well, jusb provides such capability. Take a quick look at http://jusb.sourceforge.net/apidoc/usb/core/USBListener.html. It's an interface you implement to get notified about usb events. – Sterpu Mihai Nov 19 '12 at 09:35
0

Java 7.0 introduced the new API WatchService. Combined with the linux-command 'mount', i've found a working solution.

See http://arjenmaxnet.blogspot.nl/2014/01/detecting-usb-devices-with-java-70.html

Arjen Rodenhuis
  • 199
  • 1
  • 3