JNI
2016-01-02 16:12
316 查看
JNI——Java Native Interface
新建java工程,使用eclipse
进入src目录,编译
javac JniTest.java
生成头文件
javah -jni jnitest.Jnitest
编写.cpp文件
生成dll
gcc -shared -o xmjni.dll jnitest_JniTest.cpp
拷贝dll到工程根目录下,eclipse,run
hello word.
hello, i am jni, i am succeed.
新建java工程,使用eclipse
package jnitest; public class JniTest { static{ System.loadLibrary("xmjni"); } public native void printHello(); public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("hello word."); new JniTest().printHello(); } }
进入src目录,编译
javac JniTest.java
生成头文件
javah -jni jnitest.Jnitest
编写.cpp文件
#include <jni.h> #include "jnitest_JniTest.h" #include <stdio.h> JNIEXPORT void JNICALL Java_jnitest_JniTest_printHello (JNIEnv *, jobject){ printf("hello, i am jni, i am succeed.\n"); }
生成dll
gcc -shared -o xmjni.dll jnitest_JniTest.cpp
拷贝dll到工程根目录下,eclipse,run
hello word.
hello, i am jni, i am succeed.
相关文章推荐
- 链表
- myeclipse的相关设置
- 第 19 章 多文档界面
- 01 Matrix 杭电2015年12月校赛F (二维DP)
- 安装插件 使VIM自动补齐
- 借助TinyXml,C++实现Unity的PlayerPrefs 功能
- Fedora 20及以上版本在桌面显示图标
- vi编辑器基本使用方法
- EditText限制输入数字,精确到小数点后1位设置
- 亿级用户下的新浪微博平台架构
- curl 单个请求和多个请求
- (7)基于hadoop的简单网盘应用实现3
- socket笔记
- 账号menu
- bzoj 1449 [JSOI2009]球队收益(费用拆分,最小费用流)
- 使用keytool生成证书和秘钥
- 【python下使用OpenCV实现计算机视觉读书笔记4】保存摄像头视频
- 如何让神经网络把熊猫识别为秃鹫
- python基础
- Java 直线、多段线画板 PaintJFrame (整理)