简体   繁体   English

Java无法在Eclipse项目中加载库

[英]Java not able to load library in Eclipse project

I'm trying to load a .dll into my java/c++ project in eclipse. 我正在尝试在Eclipse中将.dll加载到我的java / c ++项目中。 I've created the .dll in order for my Java project to use it with the JNI, but when I try to load the library, I get this message: "java.lang.UnsatisfiedLinkError: no hpaprogram in java.library.path". 我创建了.dll,以便Java项目将其与JNI一起使用,但是当我尝试加载该库时,出现以下消息:“ java.lang.UnsatisfiedLinkError:java.library.path中没有hpaprogram” 。 My main class is located in a different directory than the dll, but I used the flag -Djava.library.path=jni in VM Arguments. 我的主类位于与dll不同的目录中,但是我在VM Arguments中使用了-Djava.library.path=jni标志。 I have no idea what could be going wrong, and I've been debugging this for hours. 我不知道可能出什么问题,并且我已经调试了好几个小时。

Here's my git repo: https://github.com/zalbhathena/Thesis-Test-Application 这是我的git回购: https : //github.com/zalbhathena/Thesis-Test-Application

Also I'm using OS X if that matters. 如果有问题,我也正在使用OSX。

EDIT: Here's a post I found. 编辑:这是我发现的帖子。 it states that I need a jnilib, not a dll. 它指出我需要一个jnilib,而不是一个dll。 I've made the changes yet I still get the same error. 我进行了更改,但仍然遇到相同的错误。 I'm doing exactly what he is but in eclipse, so I'm not sure what's wrong. 我只是在做他的事,但是在日食中,所以我不确定是怎么回事。

Check if this helps: How to set the java.library.path from Eclipse 检查是否有帮助: 如何从Eclipse设置java.library.path

Also, maybe we can try this another way, if not already tried. 另外,也许我们可以尝试另一种方式(如果尚未尝试过)。

a) Create your java class having the native methods defined. a)创建定义了本机方法的Java类。

b) Use javah to generate the required header and c files ( http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javah.html ). b)使用javah生成所需的头文件和c文件( http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javah.html )。

c) Put in your code in the C file generated and use gcc to create a library of the same. c)将代码放入生成的C文件中,并使用gcc创建相同的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM