看来就是JNI的问题,一般java书中都有。
解决方案 »
- java.sql.SQLException: No suitable driver 在线等...
- 请问这个类在api里怎么没有帮助文档呀,那他的文档在哪sun.audio.AudioStream
- 子类的构造函数用this 或者super,为什么用this不对啊
- 哪位大侠给看看这句话的意思?(多态调用递归)
- java.exe问题,帮忙,很简单
- frame无法显示,请帮忙
- 请问什么样的东西才能被拖拽啊
- 如何获得客户端IP地址?在线等
- 为什么我装的jdk里面没有javax.servlet这个包?
- 终于连上了NOTES数据库,欢迎有这面经验的人进来讨论!!
- 有没有Struts高手?有没有网站介绍struts的网站?
- 挑战java高手
In the same directory create a java source called JavaHowTo.java class JavaHowTo {
public native String sayHello();
static {
System.loadLibrary("javahowto");
}
}
Compile the Java program and use javah utility to generate the JavaHowTo.h header file. javah -jni JavaHowTo
In MSVC6, add the JavaHowTo.h in your project header files
In the Tools - Options menu, set the include directories to include the Java JNI headers files. They are located in [jdk dir]\include and [jdk dir]\include\win32 directories
In the javahowto.cpp source, add #include "JavaHowTo.h" JNIEXPORT jstring JNICALL Java_JavaHowTo_sayHello
(JNIEnv *env, jobject obj) {
return env->NewStringUTF("Hello world");
}
Select the Release configuration and build the project.
Copy the javahowto.dll in the same directory as the java program.
Create this new java program public class JNIJavaHowTo {
public static void main(String[] args) {
JavaHowTo jht = new JavaHowTo();
System.out.println(jht.sayHello());
}
}
Compile and execute.
http://java.sun.com/j2se/1.3/docs/guide/jni/index.html
对不起,我们不使用微软的windows
to all
JNI在一般书中只介绍C调用Java类,但对Java类调用C不介绍(至少我看的几本书没介绍),如果大虾知道如何做,请详细说明.
{
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的文档说明!!
这个方法我听说过,但没有试验,谢谢!