当前位置: 技术问答>java相关
java与C的合用问题
来源: 互联网 发布时间:2015-04-14
本文导语: 如何让java调用标准C写的模块? | public class javahook extends Thread { public native boolean install_hook(); public native boolean uninstall_hook(); public native String get_hook_result(); String rs=""; prote...
如何让java调用标准C写的模块?
|
public class javahook extends Thread
{
public native boolean install_hook();
public native boolean uninstall_hook();
public native String get_hook_result();
String rs="";
protected Thread thread;
static
{
System.loadLibrary("jhook");
}
public javahook()
{
}
public void run()
{
install_hook(); //install the hook
while(true)
{
rs=get_hook_result();//这个就是调用c中的方法(装在dll中)
System.out.println("....."+rs+".....");
if(rs=="exit") break;
try {
// if(rs=="") Thread.sleep(100);
Thread.sleep(50);
} catch (Exception e) {}
}
uninstall_hook(); //uninstall the hook
}
public String get_result()
{
return rs;
}
}
看sun的文档说明!!
{
public native boolean install_hook();
public native boolean uninstall_hook();
public native String get_hook_result();
String rs="";
protected Thread thread;
static
{
System.loadLibrary("jhook");
}
public javahook()
{
}
public void run()
{
install_hook(); //install the hook
while(true)
{
rs=get_hook_result();//这个就是调用c中的方法(装在dll中)
System.out.println("....."+rs+".....");
if(rs=="exit") break;
try {
// if(rs=="") Thread.sleep(100);
Thread.sleep(50);
} catch (Exception e) {}
}
uninstall_hook(); //uninstall the hook
}
public String get_result()
{
return rs;
}
}
看sun的文档说明!!