简体   繁体   English

如何在Eclipse中生成JNI头文件

[英]How to generate JNI header file in Eclipse

I am using Eclipse to generate a JNI header file. 我正在使用Eclipse生成JNI头文件。 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. 我查看了program files\\java\\jre6\\bin ,发现了很多.exe.dll文件,但是我找不到命令javah ,它在文档中用于使用JNI创建与C库的绑定。
Any help? 有帮助吗?

Use the following panel to define a new external tool for javah.exe. 使用以下面板为javah.exe定义新的外部工具。

Point "Location" to the javah.exe tool. 将“Location”指向javah.exe工具。

Set "Working Directory" to 将“工作目录”设置为

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

Set "Arguments" to: 将“Arguments”设置为:

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

在此输入图像描述

To run the tool, highlight the java source file in package explorer and run the tool. 要运行该工具,请突出显示包浏览器中的java源文件并运行该工具。

在此输入图像描述

Press F5 to refresh th project to see the newly generated file. 按F5刷新项目以查看新生成的文件。

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

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. 用引号括起路径确实有助于上面的解决方案。

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} -classpath $ {project_classpath} -v -d $ {workspace_loc:/ $ {project_name} / jni} $ {java_type_name}

open java class and run tools 打开java类并运行工具

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM