简体   繁体   中英

loading more than one dll in the same project with jni

I have project cli c++ that i need it in java so i'm using jni to access to these methods, and it's fine with a sample project that is have no dll references but when i include any other dll the jre crashed,

for more detail i have this example:

test is the first cli c++ project that is using dllNet and i use i in my java project:

test code:

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 code:

using System;

namespace dllNet
{
    public class Class1
    {
        public static void SayHi()
        {
            System.Console.WriteLine("Hiiiiiiiiiiiiiiiiii .....");
        }
    }
}

java code:

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

and this is th error:

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

You can't, and you don't need to, load the C# DLL. You only need to load the DLL that contains your JNI code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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