java使用JNI调用C++函数
网上有了很多这样的文章,不过感觉并不是很全,我都东找西找才最终把JAVA调用c++给搞定。
下面引用了很多网上已经有的的内容,我在这里只是整合一次,让以后的朋友少走网路。
多说无益,具体如下:
作者:mykoma
假设所有文件都放在d:\
Step 1:
写JAVA文件
例如程序testdll.java,内容为:
public class testdll {
static{
System.loadLibrary("testdll");
}
public native static int get();
public native static void set(int i);
public static void main(String[] args) {
testdll test = new testdll();
test.set(10);
System.out.println(test.get());
}
}
用javac testdll.java编译它,会生成testdll.class。
再用javah testdll,则会在当前目录下生成testdll.h文件,这个文件需要被C/C++程序调用来生成所需的库文件。
Step 2:
根据testdll.h写C++文件testdll.cpp
testdll.cpp内容为:
#include "testdll.h"
int i = 0;
JNIEXPORT jint JNICALL Java_testdll_get (JNIEnv *, jclass) {
return 2*i;
}
JNIEXPORT void JNICALL Java_testdll_set (JNIEnv *, jclass, jint j) {
i = j;
}
Step 3:
生成testdll.dll
这一步需要注意,我最开始也是找了很多资料才弄正确
这里我使用的V
相关文档:
jjhou.csdn.net里面有
--------------------------------------------------------------------------------
在 console mode 中使用 C/C++ 编译器
侯捷 1999.04.08
......
(转载标签:fckeditorit 分类:Java)
1.将FCKeditor目录下的editor拷贝到项目的WebContent目录下
2.并把ECKeditor-2.3.jar 和 commons-fileupload.jar拷贝到项目\WebContent\WEB-INF\lib目录下
3.把 FCKeditor.tld拷贝到项目\WebContent\WEB-INF下
4.在web.xml里添加如下代码
代码
<servlet> ......
Java ASM
我们知道Java是静态语言,而python、ruby是动态语言,Java程序一旦写好很难在运行时更改类的行为,而python、ruby可以。
不过基于bytecode层面上我们可以做一些手脚,来使Java程序多一些灵活性和Magic,ASM就是这样一个应用广泛的开源库。
ASM is a Java bytecode manipulation framework. It can be used t ......
import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import javax.crypto.Cipher;
// 公钥加密,私钥解密示例程序
public class A {
& ......