用servlet实现jnative调用c++写的dll的例子
2011-03-23 14:25
337 查看
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/HTML");
JNative n = null;
int result = 0;
try {
n = new JNative("dllCall", "add"); //创建并初始化一个jnative对象(dll,方法)
n.setRetVal(Type.INT); //设置返回值的类型
int i=0;
n.setParameter(i++, 2);//设置参数值
n.setParameter(i++, 3);
n.invoke(); //调用dll方法
result = Integer.parseInt(n.getRetVal());//获取返回值
System.out.println(result);
PrintWriter out = response.getWriter();
out.write("<h1>"+result+"<h1>");//输出到jsp页面
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
throws ServletException, IOException {
response.setContentType("text/HTML");
JNative n = null;
int result = 0;
try {
n = new JNative("dllCall", "add"); //创建并初始化一个jnative对象(dll,方法)
n.setRetVal(Type.INT); //设置返回值的类型
int i=0;
n.setParameter(i++, 2);//设置参数值
n.setParameter(i++, 3);
n.invoke(); //调用dll方法
result = Integer.parseInt(n.getRetVal());//获取返回值
System.out.println(result);
PrintWriter out = response.getWriter();
out.write("<h1>"+result+"<h1>");//输出到jsp页面
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
相关文章推荐
- C++ 编写、 调用 dll 简单例子
- 一种实现 Java调用C++的DLL的方法
- C++调用C#的Dll实现Xml读写
- 一种实现 Java调用C++的DLL的方法
- Java调用C/C++实现的DLL动态库——JNI
- Java调用C/C++实现的DLL动态库——JNI
- 在VS2015中用C++创建DLL并用C#调用且同时实现对DLL的调试
- C# 调用C++写的dll的实现方法
- 在VS2015中用C++创建DLL并用C++调用且同时实现对DLL的调试
- C++调用C#的DLL实现方法
- JAVA中利用JNI与VS2012实现C/C++的DLL调用
- Java调用C/C++实现的DLL动态库——JNI
- 在VS2015中用C++创建DLL并用C#调用且同时实现对DLL的调试
- Java调用C/C++实现的DLL动态库——JNI(转)
- Java调用dll例子,JNative的使用
- C++调用dll例子
- C# 调用C++ CLR dll类库时,实现从 string 到 sbyte* 的转换
- Unity3d 调用 Luajit C++ DLL 实现调用 Lua脚本
- 在VS2015中用C++创建DLL并用C++调用且同一时候实现对DLL的调试
- 使用 SWIG 实现 Java 调用 C++ DLL