来源:http://omtlab.com/java-run-javah-from-eclipse/
Java – Run javah from Eclipse
javah is use to create C header file for JNI. This tutorial explain how to run javah from Eclipse.
Create project structure as shown in below image.
Create project omtJavah and create package com.omt.javah as shown in above image.
Now create new java class JavaH.java in com.omt.javah package.
JavaH.java
Copy Below code in JavaH.java
|
1
2
3
4
5
|
package
com.omt.javah;
public
class
JavaH {
public
native
void
omtJavaH();
}
|
JavaH.java contains only one native methods ( public native void omtJavaH(); ).
Now we need to create Header (.h) file for JavaH.java class. For that we need to run javah -jni. We do this things using eclipse.
Select JavaH.java file and Goto “Run > External Tools > External Tools Configurations..” as shown in below image.
Click on External Tools Configurations.. it will open windows that shown in below image.
1. Select Program
2. Click on new button to add new Configurations..
Now Fill below information in new configuration window.
1. Enter your configuration name. Here we entered Run_javah.
2. Select Location of javah.exe for that click on “Browse File System” button and select javah.exe file.
3. Select Working Directory path. This is your bin folder path of current project for that you need to click on “Browse Workspace” button and select bin folder of your current project. (Here we select omtJavah/bin )
4. Now Enter Below Arguments :
|
1
2
3
|
-jni -verbose -d
"${project_loc}${system_property:file.separator}jni"
${java_type_name}
Copy Above line in Arguments
|
在这一步遇到错误,google后终于解决问题,Arguments模块下我是这样填写的:
Now click on run button to create Header (.h) file of JavaH.java.
Refresh your project you will see following files and folder.
本文介绍如何在Eclipse环境中使用javah工具为Java本地接口(JNI)创建C头文件。通过逐步指导创建项目结构、Java类,并配置外部工具运行javah命令。





504

被折叠的 条评论
为什么被折叠?



