java使用jni调用一个NativeTest.dll,这个NativeTest.dll集成了图像优化处理的这么一个ocr.dll和图像识别代码,
在NativeTest.DLL里面调用ocr.DLL的函数的时候就出现这么一个错误:如下,恳请大侠们帮忙拉,解决马上结贴给分,不够分数可以再加。------------------------------------------------------------------------
        Fatal Java Exception detected at Wed Sep 03 13:30:55 2008
------------------------------------------------------------------------
Please follow these steps in reporting this problem to The MathWorks so
that we have the best chance of correcting it:    1. Send us this crash report.  For your convenience, this information
       has been recorded in: C:\DOCUME~1\user\LOCALS~1\Temp\java.log.2864    2. Provide a brief description of what you were doing when this
       problem occurred.    3. If possible, include M-files, MEX-files, or MDL-files that aid
       in reproducing it.    4. E-mail or FAX this information to us at:
                  E-mail:   [email protected]
                     FAX:   508-647-7201Thank you for your assistance.

解决方案 »

  1.   

    java代码如下:
    public class CESHI {
        public CESHI() {
           // System.out.println(System.getProperty("java.library.path"));
            System.loadLibrary("NativeTest");//这里是最后封装的DLL供JAVA应用程序调用
        }
        public native String ocrimage(String name);//NativeTest.DLL的函数    public static void main(String[] args) {
            CESHI test = new CESHI();
            String str = "K:\\CESHI\\DSC04769.JPG";
            String ResultStr = test.ocrimage(str);   //NativeTest.DLL函数的调用,也是问题出现在这里
            System.out.println("the result of the application is" +ResultStr);    }
    }//NativeTest.DLL代码:CString ocrimage(CString name); 
    #pragma comment(lib,"OCRDLL")      //调用OCR.DLL,提供ocrimage方法处理JNIEXPORT jstring JNICALL Java_CESHI_ocrimage
    (JNIEnv *env, jobject jobj, jstring str){
        AfxMessageBox(env-> GetStringUTFChars(str,false));//这一步程序可以正确获得
        CString CSjs=ocrimage(env->GetStringUTFChars(str,false));  //执行到这里就出错了!!!后面不执行
        //ocrimage是OCR.DLL里面的一个方法    AfxMessageBox("2");
        jstring js;
        char *cCSjs;
        cCSjs=CSjs.GetBuffer(0);
    AfxMessageBox("3");
        js=convertANSIToUNI(env,cCSjs);
    AfxMessageBox("4");
        return js;
    }
      

  2.   

    你调用OCR库就是为了解决Java到本地代码的字符串转换问题?
      

  3.   

    不是,env->GetStringUTFChars(str,false)这里已经解决Java到本地代码的字符串转换了,我调用
    OCR库是为了处理图像(有窗体的,不知道dos能不能调用有窗体的dll呢)
      

  4.   

    DLL调用DLL出问题,不是Java的问题,可能是路径的问题了,尽量把你的ocr.dll放到这个dll同目录下,或者system32下。OCR是指代那些用模式识别等技术进行手写识别的技术,等等。
      

  5.   

    我的ocr.dll就是放在跟这个dll同目录下,但是这个ocr.dll被vc++ mfc exe调用就能正常使用,但是给java的dll调用就出问题拉,为什么?请给我点提示吗大家
      

  6.   

    会不会java通过jni调用vc++的时候不能再调用matlab的dll啊?