I want to monitor portable devices attached to my linux OS using jmtp.jar. Below is the code that i am using to do the same. It's working fine in Windows but when i run this code it gives me "Not supported OS exception". do jmtp.jar support linux OS? If not then any alternative solution for linux OS?
Code that i used
import java.io.*;
import java.math.BigInteger;
import jmtp.PortableDevice;
import jmtp.PortableDeviceManager;
import jmtp.PortableDeviceObject;
import jmtp.PortableDeviceStorageObject;
public class Jmtp {
public static void main(String[] args) {
PortableDeviceManager manager = new PortableDeviceManager();
PortableDevice device = manager.getDevices()[0];
device.open();
System.out.println(device.getModel());
System.out.println("---------------");
// Iterate over deviceObjects
for (PortableDeviceObject object : device.getRootObjects()) {
// If the object is a storage object
if (object instanceof PortableDeviceStorageObject) {
PortableDeviceStorageObject storage = (PortableDeviceStorageObject) object;
for (PortableDeviceObject o2 : storage.getChildObjects()) {
System.out.println(o2.getOriginalFileName());
}
}
}
manager.getDevices()[0].close();
}
}
Exception that i got :
Exception in thread "main" java.lang.RuntimeException: not supported os
at jmtp.PortableDeviceManager.<init>(PortableDeviceManager.java:37)
at find_usb.Jmtp.main(Jmtp.java:24)
Google states: