2

我想使用 jmtp.jar 监视连接到我的 linux 操作系统的便携式设备。下面是我用来做同样事情的代码。它在 Windows 中运行良好,但是当我运行此代码时,它给了我“不支持的操作系统异常”。jmtp.jar 支持 linux 操作系统吗?如果没有,那么 Linux 操作系统的任何替代解决方案?

我使用的代码

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 in thread "main" java.lang.RuntimeException: not supported os
    at jmtp.PortableDeviceManager.<init>(PortableDeviceManager.java:37)
    at find_usb.Jmtp.main(Jmtp.java:24) 
4

1 回答 1

0

谷歌声明:

A project aimed at allowing java programs to access MTP compabitble portable 
media players. The main target is currently windows, by wrapping the WPD api, 
but design decisions have been made to support both linux and mac os x in 
the future with the same API. For more information, please see the wiki. 
于 2014-09-01T08:40:44.613 回答