我有以下应该加载两个dll的代码:
public class ArcgisJniNet {
static{
System.load("D:/Users/User/Desktop/DLL/comCorporateProject.dll");
System.load("D:/Users/User/Desktop/DLL/FileGDBAPI.dll");
}
//Native method declaration
private native void FileGDBApi();
public void test(){
ArcgisJniNet arcgisJniNet = new ArcgisJniNet();
arcgisJniNet.FileGDBApi();
}
}
但是,当我在karaf中部署并运行服务调用时,它将引发以下错误:
Caused by: java.lang.UnsatisfiedLinkError:
D:\Users\User\Desktop\DLL\comCorporateProject.dll: Can't find dependent
libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)[:1.8.0_162]
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)[:1.8.0_162]
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)[:1.8.0_162]
at java.lang.Runtime.load0(Runtime.java:809)[:1.8.0_162]
at java.lang.System.load(System.java:1086)[:1.8.0_162]
at com.corporate.ex.services.arcgis.service.ArcgisJniNet.<clinit>
(ArcgisJniNet.java:5)
我已经在环境变量中设置了dll文件夹的路径,并重新启动了我的计算机,但看来我仍然面临这个问题。
我的C ++实现如下所示:
#include "stdafx.h"
#include "comCorporateProject.h"
#include <FileGDBAPI.h>
using namespace FileGDBAPI;
using namespace std;
JNIEXPORT void JNICALL
Java_com_corporate_ex_services_arcgis_service_ArcgisJniNet_FileGDBApi
(JNIEnv *, jobject) {
fgdbError hr;
Geodatabase gdb;
if ((hr =
CreateGeodatabase(L"D:/Users/User/Desktop/geodb/example.gdb", gdb)) !=
S_OK)
{
wcout << "An error occurred while creating the geodatabase.";
}
wcout << "An error occurred while creating the geodatabase.";
CloseGeodatabase(gdb);
}
我的意图是从将部署在服务器中的java代码jar中调用c ++函数。我不确定为什么它告诉我在提供正确的绝对路径后找不到dll。请指出我犯的错误。感谢您的指导。