从applet调用JNI方法时没有错误消息

时间:2015-04-02 02:48:42

标签: java java-native-interface

我从applet通过Java Native Interface调用动态库文件(Visual C ++)。问题是即使我处理try / catch错误处理我也无法在" Java控制台"中看到异常细节。我可以从哪里得到错误详情吗?我确信它必须是日志文件中的某个位置。

下面是代码。

import java.security.AccessController;
import java.security.PrivilegedAction;

public class TempletGenerator {

    static {
         try
            {
                AccessController.doPrivileged(new PrivilegedAction()
                {
                    public Object run()
                    {
                        try
                        {

                             System.out.println("Loading.. TempletGen");    
                             System.out.println("java.library.path=="+System.getProperty("java.library.path"));

                            // privileged code goes here, for example:

                             System.loadLibrary("SourceAFIS");
                             System.loadLibrary("TempSample");
                             System.loadLibrary("TempletGen");

                             System.out.println("Successfully loaded TempletGen");                     
                            return null; // nothing to return
                        }
                        catch (Exception e)
                        {
                            System.out.println("Error "+e.getMessage());
                            e.printStackTrace();
                            return null;
                        }
                    }
                 });
            }
            catch (Exception e)
            {
                System.out.println("Error "+e.getMessage());

                e.printStackTrace();
            }
    }

    public native String getTemplate(byte[] byteArray, String name);


    public String getTempletData(byte[] byteArray, String name){
        try{
            System.out.println("TempletGenerator.getTempletData");
            TempletGenerator tg = new TempletGenerator();

            return tg.getTemplate(byteArray, name);
        }catch(Exception e){
            System.out.println("Error details ......." + e.getMessage());
        }
        return "";
    }
}

提前致谢!

0 个答案:

没有答案