如何在Eclipse中生成JNI头文件

时间:2022-10-26 02:05:08

I am using Eclipse to generate a JNI header file. I looked in program files\java\jre6\bin and found a lot of .exe and .dll files, but I couldn't find the command javah which was in the documentation for using JNI to create bindings to C libraries.
Any help?

我正在使用Eclipse生成JNI头文件。我查看了程序文件\java\jre6\bin并找到了许多.exe和.dll文件,但是我找不到文档中使用JNI创建到C库的绑定的命令javah。任何帮助吗?

3 个解决方案

#1


32  

Use the following panel to define a new external tool for javah.exe.

使用以下面板为java .exe定义一个新的外部工具。

Point "Location" to the javah.exe tool.

将“位置”指向javah。exe工具。

Set "Working Directory" to

“工作目录”

${workspace_loc:/${project_name}/bin}

Set "Arguments" to:

“参数”设置为:

-classpath ${project_classpath} -v -d ${workspace_loc:/${project_name}/src} ${java_type_name}

如何在Eclipse中生成JNI头文件

To run the tool, highlight the java source file in package explorer and run the tool.

要运行该工具,请在package explorer中突出java源文件并运行该工具。

如何在Eclipse中生成JNI头文件

Press F5 to refresh th project to see the newly generated file.

按F5刷新项目以查看新生成的文件。

#2


2  

Just some info...

只是一些信息…

Unfortunately the solution above did not work out for me, but the solution in this thread did:

不幸的是,上面的解决方案对我不起作用,但是这个线程中的解决方案却起了作用:

Using javah -jni with an Eclipse project structure

使用javah -jni与Eclipse项目结构。

With the above mentioned arguments, I got:

通过上述论证,我得到:

Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name:path/to/project

线程“main”java.lang中的异常。IllegalArgumentException:不是一个有效的类名:path/to/项目。

I found out, that the problem was a space character in the path to my project. Wrapping the paths in quotes did help for the solution above.

我发现,问题出在我项目的路径上。用引号括起路径对上面的解决方案确实有帮助。

#3


0  

Location

位置

// javah.exe path

/ / javah。exe路径

C:\Program Files\Java\jdk1.7.0_79\bin\javah.exe

C:\Program Files\Java\ jdk1.7.0_79 \ bin \ javah.exe

Working Directory

工作目录

${workspace_loc:/${project_name}/bin}

$ { workspace_loc:/ $ { project_name } / bin }

Arguments

参数

-classpath ${project_classpath} -v -d ${workspace_loc:/${project_name}/jni} ${java_type_name}

-类路径${project_classpath} -v -d ${workspace_loc:/${project_name}/jni} ${java_type_name}

open java class and run tools

打开java类并运行工具

#1


32  

Use the following panel to define a new external tool for javah.exe.

使用以下面板为java .exe定义一个新的外部工具。

Point "Location" to the javah.exe tool.

将“位置”指向javah。exe工具。

Set "Working Directory" to

“工作目录”

${workspace_loc:/${project_name}/bin}

Set "Arguments" to:

“参数”设置为:

-classpath ${project_classpath} -v -d ${workspace_loc:/${project_name}/src} ${java_type_name}

如何在Eclipse中生成JNI头文件

To run the tool, highlight the java source file in package explorer and run the tool.

要运行该工具,请在package explorer中突出java源文件并运行该工具。

如何在Eclipse中生成JNI头文件

Press F5 to refresh th project to see the newly generated file.

按F5刷新项目以查看新生成的文件。

#2


2  

Just some info...

只是一些信息…

Unfortunately the solution above did not work out for me, but the solution in this thread did:

不幸的是,上面的解决方案对我不起作用,但是这个线程中的解决方案却起了作用:

Using javah -jni with an Eclipse project structure

使用javah -jni与Eclipse项目结构。

With the above mentioned arguments, I got:

通过上述论证,我得到:

Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name:path/to/project

线程“main”java.lang中的异常。IllegalArgumentException:不是一个有效的类名:path/to/项目。

I found out, that the problem was a space character in the path to my project. Wrapping the paths in quotes did help for the solution above.

我发现,问题出在我项目的路径上。用引号括起路径对上面的解决方案确实有帮助。

#3


0  

Location

位置

// javah.exe path

/ / javah。exe路径

C:\Program Files\Java\jdk1.7.0_79\bin\javah.exe

C:\Program Files\Java\ jdk1.7.0_79 \ bin \ javah.exe

Working Directory

工作目录

${workspace_loc:/${project_name}/bin}

$ { workspace_loc:/ $ { project_name } / bin }

Arguments

参数

-classpath ${project_classpath} -v -d ${workspace_loc:/${project_name}/jni} ${java_type_name}

-类路径${project_classpath} -v -d ${workspace_loc:/${project_name}/jni} ${java_type_name}

open java class and run tools

打开java类并运行工具