包括Netbeans中的本地库 [英] Including Native Library in Netbeans

查看:139
本文介绍了包括Netbeans中的本地库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从java签名的applet中读取便携式设备....
我在
上找到了一个jmtp库 http://code.google.com/p/jmtp/w/list 可以访问便携式设备但是当我在netbeans中运行它时会出现错误

I am trying to read portable devices from java signed applet.... I found a jmtp library on http://code.google.com/p/jmtp/w/list to get access to portable devices but when i run it in netbeans it gives error


    Exception in thread "main" java.lang.UnsatisfiedLinkError: no jmtp in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
        at java.lang.Runtime.loadLibrary0(Runtime.java:845)
        at java.lang.System.loadLibrary(System.java:1084)
        at jmtp.PortableDeviceManagerImplWin32.(PortableDeviceManagerImplWin32.java:38)
        at jmtp.PortableDeviceManager.(PortableDeviceManager.java:34)
        at jmtp.Jmtp.main(Jmtp.java:23)
    Java Result: 1
    

我搜索并发现我必须将.dll文件包含在jmtp项目中作为本机库...
我正确 - 点击第roject并导航到属性,然后选择Run和Selected VM Option as

I searched and found that i have to include .dll file as native library in project of jmtp... I right-clicked on project and navigated to properties and then Selected "Run" and Selected VM Option as

-Djava.library.path="c:\jmtp\native\windows"


并将jmtp.dll文件放在c:\ _jmtp文件夹中

and placed that jmtp.dll file in c:\jmtp folder

但是同样的错误经常出现
我的代码是

But same error appears constantly my code is


    package jmtp;
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]; 

        // Connect to my mp3-player
        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.getName());
                 }              
            }
        }
        manager.getDevices()[0].close();

    }
}

请告诉我是什么问题

推荐答案

最后我找到解决方案,为了包含本机库,我们需要在netbeans中添加以下步骤

Finally i found the solution, In order to include native library we need to add following steps in netbeans


     ==>Right click on the Project
     ==>Properties
     ==>Click on RUN
     ==>VM Options : -Djava.library.path="C:\Your Directory where Dll is present"
     ==>Ok
    

这篇关于包括Netbeans中的本地库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆