2012-12-27 66 views
0

我有項目cli C++,我需要它在java中,所以我使用jni來訪問這些方法,並且它沒有dll引用的示例項目但是當我包括任何其他的dll的JRE墜毀,與jni在同一個項目中加載多個dll

更多細節我有這樣的例子:

測試是使用dllNet第一CLI的C++項目,我用我在Java項目:

測試代碼:

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

回答

-1

你不能,你不需要,負載C#DLL。你只需要加載包含你的JNI代碼的DLL。

+0

你顯然不明白這個問題 –

+0

@fredericknyawaya他有一個名爲'dllNet'的C++ DLL沒有JNI調用,他試圖用'System.load()'加載它,這是無效的。你不瞭解哪一部分? – EJP

+0

現在,dllNet有其他dll引用導致jre崩潰,他顯然沒有問題加載沒有依賴關係的dll。那麼如果包含jni代碼的dll引用了其他dll,你會怎麼做? –