解决方案 »
- io中修饰模式
- 新手求助一个关于System.in.resd()的小问题
- JAVA如何实现象 星际争霸 主机掉线 其他分机还可以继续通信的!?
- 浮点数加法精度问题,两种处理方式结果不同,大家帮忙看看!!
- 输出的问题
- 如何取得文件的占用空间
- ChartDirector求救
- java里面老是说继承破坏封装,怎么理解啊
- 我的20本Java书2007年更新
- 发现applet动画窗口嵌在网页里运行效率比较高,但是嵌在jframe窗口里运行,效率就不行
- [snmp4j]snmp4j通过getBulk要求取数据timeout,可是通过wireshark截包发现网卡已经收到包了,请问是什么原因
- 一个关于内存变量地址转换的问题
这个输出顺序是基于什么原理或依据呢?再看 在main方法中 和 在servlet 中 这个原理或依据 有没有变化,或者 上面代码执行的条件有哪些质变
普通JAVA和SERVLET调用的是同一个函数,并且是一模一样的。
普通JAVA代码
public static void main(String[] args){
Comp comp = new Comp();
comp.lgm("a.bmp", "b.bmp");
}
servlet代码public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { try {
Comp comp = new Comp();
comp.lgm("a.bmp", "b.bmp");
}catch (Exception e){
e.printStackTrace();
}
response.sendRedirect("/default.jsp");
}
被调函数public String lgm(String a,String b){
String strScore = "zheng dao.";
Comp hello = new Comp();
hello.open(); String file1 = a;//args[0];//"a.bmp";//args[0];
String file2 = b;//args[1];//"b.bmp";//args[1]; System.out.println("11111111111111111111111"); try{
int init = hello.initTHFaceID("/gfserver/lib/Work",1);
System.out.println("22222222222222222222222222"); int free = hello.freeTHFaceID(1);
}catch(Exception e){ System.out.print("Pserrorerrorerrorerror:"+e.toString());
e.printStackTrace();
} System.out.println("333333333333333333333333333333");
hello.close(); System.out.println("444444444444444444444444444444444");
return strScore;
}第三方厂商提供我们一个SO文件,里面有初始化资源函数,释放初始化资源函数,还有其他涉及业务的函数。。通过编写一个普通JAVA main程序可以调用成功。首先OPEN SO动态链接库,然后打出1111,然后又初始化资源,然后打印2222,然后打出3333,然后释放资源,然后CLOSE so资源,最后打出4444这样的顺序。但是我将同样的程序写在java servlet web工程下,为什么就执行就不对。
1.首先顺序不对,先打出111没有错,然后分别打出22222,3333,然后才OPENT SO动态链接,然后初始化资源,然后释放资源,然后CLOSE SO资源(此时关闭错误),并且4444没有打印出来。难道是第三方提供的动态链接库不支持B/S结构的,或者是他们的SO中函数有另外的线程与JAVA SERVLET 线程不同步。仅仅开了一个SERVLE,就是说我是通过但线程执行的啊。
还有就是 楼上讲的 hello.close 出错了,什么错误,将close方法和错误信息贴出来
public String lgm(String a,String b){
String strScore = "zheng dao.";
Comp hello = new Comp();
hello.open();
String file1 = a;//args[0];//"a.bmp";//args[0];
String file2 = b;//args[1];//"b.bmp";//args[1];
System.out.println("11111111111111111111111");
try{
int init = hello.initTHFaceID("/gfserver/lib/Work",1);
System.out.println("22222222222222222222222222");
int free = hello.freeTHFaceID(1);
}catch(Exception e){
System.out.print("Pserrorerrorerrorerror:"+e.toString());
e.printStackTrace();
}
System.out.println("333333333333333333333333333333");
hello.close(); //close到这里就进行不下去了,4444没有打印出来。
System.out.println("444444444444444444444444444444444");
return strScore;
}
public String lgm(String a,String b){
String strScore = "zheng dao.";
Comp hello = new Comp();
hello.open();
String file1 = a;//args[0];//"a.bmp";//args[0];
String file2 = b;//args[1];//"b.bmp";//args[1];
System.out.println("11111111111111111111111");
try{
int init = hello.initTHFaceID("/gfserver/lib/Work",1);
System.out.println("22222222222222222222222222");
int free = hello.freeTHFaceID(1);
}catch(Exception e){
System.out.print("Pserrorerrorerrorerror:"+e.toString());
e.printStackTrace();
}
System.out.println("333333333333333333333333333333");
hello.close(); //close到这里就进行不下去了,4444没有打印出来。
System.out.println("444444444444444444444444444444444");
return strScore;
}
断点能不能打到Comp 这个类里面呢,能的话可以看看hello.close 都做了些什么,看什么原因导致执行不下去了
imglib = dlopen("libMidCompare.so", RTLD_LAZY);// RTLD_LAZY RTLD_NOW
if(imglib!=NULL){
printf("Open libMidCompare.so with handle ok.\n");
}else{
printf("Open libMidCompare.so with handle fail!\n");
}
}JNIEXPORT void JNICALL Java_com_Compare_close(JNIEnv *env, jobject obj){
if (imglib != NULL ) {
printf("close--2 ! \n");
dlclose(imglib);
printf("close--3 ! \n");//这个没有执行
printf("Close with handle ok.\n");
}else{
printf("Close with handle fail!\n");
}
}
public String lgm(String a,String b){
String strScore = "zheng dao.";
Comp hello = new Comp();
hello.open();
String file1 = a;//args[0];//"a.bmp";//args[0];
String file2 = b;//args[1];//"b.bmp";//args[1];
System.out.println("11111111111111111111111");
try{
int init = hello.initTHFaceID("/gfserver/lib/Work",1);
System.out.println("22222222222222222222222222");
int free = hello.freeTHFaceID(1);
}catch(Exception e){
System.out.print("Pserrorerrorerrorerror:"+e.toString());
e.printStackTrace();
}
System.out.println("333333333333333333333333333333");
hello.close(); //close到这里就进行不下去了,4444没有打印出来。
System.out.println("444444444444444444444444444444444");
return strScore;
}