0

我有项目cli c++,我在java中需要它,所以我使用jni来访问这些方法,并且没有dll引用的示例项目很好,但是当我包含任何其他dll时,jre崩溃了,

有关更多详细信息,我有这个例子:

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 .....");
        }
    }
}

爪哇代码:

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.
#
4

1 回答 1

-1

您不能也不需要加载 C# DLL。您只需要加载包含您的 JNI 代码的 DLL。

于 2013-01-01T00:20:10.323 回答