我有项目cli c ++,我需要它在java中,所以我使用jni访问这些方法,并且没有dll引用的示例项目,但当我包含任何jre坠毁的其他dll,
更多细节我有这个例子:
test是第一个使用dllNet的cli c ++项目,我在我的java项目中使用i:
测试代码:
using namespace dllNet;
JNIEXPORT jstring JNICALL Java_alquasar_aimetis_AimetisCallJNI_getAllCameras
(JNIEnv *env, jclass cls, jobject srv, jobject cams){
dllNet::Class1::SayHi();
return env->NewStringUTF( "Hello, World!" );
}
dllNet代码:
using System;
namespace dllNet
{
public class Class1
{
public static void SayHi()
{
System.Console.WriteLine("Hiiiiiiiiiiiiiiiiii .....");
}
}
}
java代码:
public class AimetisCallJNI {
static{
System.load("C:/Users/alquasar/Desktop/mejdi/Aimetis/bin/dllNet.dll");
System.load("C:/Users/alquasar/Desktop/mejdi/Aimetis/bin/test.dll");
}
public static native String getAllCameras(ServerAis srv, CamerasAis list);
public static void main(String[] args) {
ServerAis srv = new ServerAis("192.168.0.42", "admin", "admin");
CamerasAis list = new CamerasAis();
new AimetisCallJNI().getAllCameras(srv, list);
}
这是错误:
A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (0xe0434f4d), pid=4956, tid=4732
#
# JRE version: 6.0_37-b06
# Java VM: Java HotSpot(TM) Client VM (20.12-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [KERNELBASE.dll+0xc6e3]
#
# An error report file with more information is saved as:
# C:\Users\alquasar\workspaceMejdi\tn.waycon.alquasar.video.aimetis.impl\hs_err_pid4956.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
答案 0 :(得分:-1)
您不能,也不需要加载C#DLL。您只需要加载包含JNI代码的DLL。