<bdo id='NDmlU'></bdo><ul id='NDmlU'></ul>

    <small id='NDmlU'></small><noframes id='NDmlU'>

  1. <tfoot id='NDmlU'></tfoot>
    <legend id='NDmlU'><style id='NDmlU'><dir id='NDmlU'><q id='NDmlU'></q></dir></style></legend>
  2. <i id='NDmlU'><tr id='NDmlU'><dt id='NDmlU'><q id='NDmlU'><span id='NDmlU'><b id='NDmlU'><form id='NDmlU'><ins id='NDmlU'></ins><ul id='NDmlU'></ul><sub id='NDmlU'></sub></form><legend id='NDmlU'></legend><bdo id='NDmlU'><pre id='NDmlU'><center id='NDmlU'></center></pre></bdo></b><th id='NDmlU'></th></span></q></dt></tr></i><div id='NDmlU'><tfoot id='NDmlU'></tfoot><dl id='NDmlU'><fieldset id='NDmlU'></fieldset></dl></div>

      JNA:本机库依赖项和 JAR 提取

      JNA: Native Library dependencies and JAR extraction(JNA:本机库依赖项和 JAR 提取)

        <small id='pn3Ie'></small><noframes id='pn3Ie'>

          <tbody id='pn3Ie'></tbody>
        <tfoot id='pn3Ie'></tfoot>

      1. <legend id='pn3Ie'><style id='pn3Ie'><dir id='pn3Ie'><q id='pn3Ie'></q></dir></style></legend>

            • <bdo id='pn3Ie'></bdo><ul id='pn3Ie'></ul>

            • <i id='pn3Ie'><tr id='pn3Ie'><dt id='pn3Ie'><q id='pn3Ie'><span id='pn3Ie'><b id='pn3Ie'><form id='pn3Ie'><ins id='pn3Ie'></ins><ul id='pn3Ie'></ul><sub id='pn3Ie'></sub></form><legend id='pn3Ie'></legend><bdo id='pn3Ie'><pre id='pn3Ie'><center id='pn3Ie'></center></pre></bdo></b><th id='pn3Ie'></th></span></q></dt></tr></i><div id='pn3Ie'><tfoot id='pn3Ie'></tfoot><dl id='pn3Ie'><fieldset id='pn3Ie'></fieldset></dl></div>
                本文介绍了JNA:本机库依赖项和 JAR 提取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我将通过 JNA 访问 MSP430.dll(参见此处).但是这个库依赖于与 MSP430.dll 捆绑在一起的其他本机库.这个依赖本机库称为 HIL.dll.使用 jna.library.path 一切都可以完美运行.现在我会将本机库捆绑到我自己的 .jar 包中.然后我会使用从 JNA 框架的 jar 中自动加载的本地库.但这会给具有依赖关系的本机库带来问题.如果我将 MSP430.dll 和 HIL.dll 打包到我的 .jar 包中,则会收到以下错误:JNA java.lang.UnsatisfiedLinkError 和找不到指定的模块".这意味着,无法将 MSP430.dll 的依赖关系解析为 HIL.dll.在 JNA 的调试输出中,我可以看到,只有 MSP430.dll 将从 .jar 包中提取.在这种情况下,错误是可以理解的.在下一条路径中,我显式加载了 HIL.dll,我可以看到 HIL.dll 的提取,然后是 MSP430.dll.但是我仍然收到来自 JNA 的模块错误.

                I will access the MSP430.dll (see here) via JNA. But this library has a dependency to other native library, which cames bundled with the MSP430.dll. This dependend native library is called HIL.dll. With use of jna.library.path all does work perfect. Now I would bundle the native librarys to my own .jar package. Then I would use the automatic native library loading from jar of the JNA framework. But this makes problems with native librarys that have dependencies. If I package the MSP430.dll and HIL.dll to my .jar package then I get following error: "JNA java.lang.UnsatisfiedLinkError and The specified module could not be found". This means, it was not possible to resolve the dependencies of the MSP430.dll to the HIL.dll. In the debug outputs of JNA i can see, only the MSP430.dll will extract from .jar package. In this context the error is understandable. In the next trail, I load the HIL.dll explicit and I can see the extraction of HIL.dll then of the MSP430.dll. But I get still the module error from JNA.

                我查看了提取方法的 JNA 代码.我看到 JNA 将本机库提取到系统临时目录并在其中创建自己的临时目录.但现在我认为问题是,JNA 为本地库创建临时文件,带有jna"前缀和唯一生成的数值.这里是 JNA 的输出:

                I have looked to the JNA code of the extraction method. I see JNA extracts the native librarys to system temp directory and creates an own temp directory in their. But now I think the problem is, JNA creats temp files for the native librarys wit "jna" prefix and a unique generated numeric value. Here the output of JNA:

                Found library 'HIL.dll' at C:UsersRD3AppDataLocalTempjna-80961jna1305152974718331988.dll
                

                我认为 MSP430.dll 需要未重命名的 HIL.dll 才能找到它.我有直接加载 HIL.dll 的 testet,并在应用程序中进行第一次调用

                I think the MSP430.dll needs the HIL.dll unrenamed for finding it. I have testet with direct loading of the HIL.dll with following as first call in the application

                System.loadLibrary(C:\absolutepath\HIL.dll);
                

                然后通过 JNA 从 .jar 包中仅加载 MSP430.dll,这没有问题.之后,我将 HIL.dll 重命名为 lol.dll 并使用此调用:

                Then loads only MSP430.dll via JNA from .jar package, this works without problems. After that I rename the HIL.dll to lol.dll and use this call:

                System.loadLibrary(C:\absolutepath\lol.dll);
                

                然后我再次从 JNA 收到模块错误.MSP430.dll 无法解析重命名的 HIL.dll.

                then I gets the module error again from JNA. The MSP430.dll was not able to resolve the renamed HIL.dll.

                是否可以将具有依赖关系的本机库打包到 .jar 包并使用 JNA 加载?

                It is anyway possible to package a native library with dependencies to .jar package and loading with JNA?

                这里是通过 JNA 显式加载 HIL.dll 的 JNA 调试输出:

                Here the JNA debug output with explicit loading of HIL.dll via JNA:

                C:UsersRD3Desktop>call "C:Program Files (x86)Javajre1.8.0_25injava.exe"
                 -Djna.debug_load=true -jar C:DataWorkspaceNetBeansMspApiTest	argetMspApiTest-1.0.0-SNAPSHOT-jar-with-dependencies.jar
                Looking in classpath from sun.misc.Launcher$AppClassLoader@1f96302 for /com/sun/jna/win32-x86/jnidispatch.dll
                Found library resource at jar:file:/C:/Data/mstandfuss/Workspace/NetBeans/MspApiTest/target/MspApiTest-1.0.0-SNAPSHOT-jar-with-dependencies.jar!/com/sun/jna/win32-x86/jnidispatch.dll
                Looking for library 'HIL.dll'
                Adding paths from jna.library.path: null
                Trying HIL.dll
                Adding system paths: []
                Trying HIL.dll
                Looking for lib- prefix
                Trying libHIL.dll
                Looking in classpath from sun.misc.Launcher$AppClassLoader@1f96302 for HIL.dll
                Found library resource at jar:file:/C:/Data/mstandfuss/Workspace/NetBeans/MspApiTest/target/MspApiTest-1.0.0-SNAPSHOT-jar-with-dependencies.jar!/win32-x86/HIL.dll
                Found library 'HIL.dll' at C:UsersRD3AppDataLocalTempjna-80961jna1305152974718331988.dll
                Looking for library 'MSP430.dll'
                Adding paths from jna.library.path: null
                Trying MSP430.dll
                Adding system paths: []
                Trying MSP430.dll
                Looking for lib- prefix
                Trying libMSP430.dll
                Looking in classpath from sun.misc.Launcher$AppClassLoader@1f96302 for MSP430.dll
                Found library resource at jar:file:/C:/Data/mstandfuss/Workspace/NetBeans/MspApi
                Test/target/MspApiTest-1.0.0-SNAPSHOT-jar-with-dependencies.jar!/win32-x86/MSP430.dll
                Exception in thread "main" java.lang.UnsatisfiedLinkError: Das angegebene Modul wurde nicht gefunden.
                
                        at com.sun.jna.Native.open(Native Method)
                        at com.sun.jna.Native.open(Native.java:1759)
                        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:260)
                        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
                        at com.sun.jna.Library$Handler.<init>(Library.java:147)
                        at com.sun.jna.Native.loadLibrary(Native.java:412)
                        at com.sun.jna.Native.loadLibrary(Native.java:391)
                        at de.sitec.jmspflash.Msp430Native.<clinit>(Msp430Native.java:22)
                        at de.sitec.jmspflash.Msp430Impl.init(Msp430Impl.java:50)
                        at de.sitec.jmspflash.Msp430Impl.createMsp430Impl(Msp430Impl.java:36)
                        at de.sitec.mspapitest.App.main(App.java:34)
                
                C:UsersRD3Desktop>
                

                最好的问候

                推荐答案

                假设您遇到的唯一问题是依赖库的名称,请参阅 Native.extractFromResourcePath().您可以使用它来提取非显式依赖项并使用 File.rename() 来确保库具有您想要的名称.

                Assuming that the only issue you're having is the name of the dependent library, see Native.extractFromResourcePath(). You can use that to extract your non-explicit dependencies and use File.rename() to ensure the library has the name you want.

                这篇关于JNA:本机库依赖项和 JAR 提取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Maven JAVA_HOME environment variable is not defined correctly, but it is(Maven JAVA_HOME 环境变量未正确定义,但它是)
                Java System Environment Variable(Java 系统环境变量)
                Java -classpath option(Java -classpath 选项)
                Read environment variable in SpringBoot(在 SpringBoot 中读取环境变量)
                Tomcat 8 - context.xml use Environment Variable in Datasource(Tomcat 8 - context.xml 在数据源中使用环境变量)
                Issue with JAVA_HOME(JAVA_HOME 的问题)
                • <tfoot id='FoJIq'></tfoot>
                    <bdo id='FoJIq'></bdo><ul id='FoJIq'></ul>

                    <small id='FoJIq'></small><noframes id='FoJIq'>

                          <tbody id='FoJIq'></tbody>
                        <i id='FoJIq'><tr id='FoJIq'><dt id='FoJIq'><q id='FoJIq'><span id='FoJIq'><b id='FoJIq'><form id='FoJIq'><ins id='FoJIq'></ins><ul id='FoJIq'></ul><sub id='FoJIq'></sub></form><legend id='FoJIq'></legend><bdo id='FoJIq'><pre id='FoJIq'><center id='FoJIq'></center></pre></bdo></b><th id='FoJIq'></th></span></q></dt></tr></i><div id='FoJIq'><tfoot id='FoJIq'></tfoot><dl id='FoJIq'><fieldset id='FoJIq'></fieldset></dl></div>

                          <legend id='FoJIq'><style id='FoJIq'><dir id='FoJIq'><q id='FoJIq'></q></dir></style></legend>