如何从 Eclipse 运行 Javah
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3451378/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run Javah from Eclipse
提问by sparkFinder
So I'm trying to run the 'javah' tool on a compiled .class file in Eclipse, but I have no idea how to do it. The examples I found simply said something along the lines of 'run javah on your class...' but I don't really know where I'd find such a command line in Eclipse.
所以我试图在 Eclipse 中编译的 .class 文件上运行“javah”工具,但我不知道该怎么做。我发现的例子只是简单地说了一些类似“在你的班级上运行 javah...”的内容,但我真的不知道在 Eclipse 中哪里可以找到这样的命令行。
If someone can give me a set of idiot proof instructions get this done in Eclipse, I'd be grateful.
如果有人可以给我一组白痴证明说明在 Eclipse 中完成这项工作,我将不胜感激。
Thanks :)
谢谢 :)
回答by josefx
AFAIK Eclipse does not integrate javah by default. You have to set it up as external tool yourself.
AFAIK Eclipse 默认不集成 javah。您必须自己将其设置为外部工具。
- Create a new external tool
- Set the path to javah (on linux this was /user/bin/javah)
- Set the working dir to
${project_loc}/bin/
where bin is your Projects output directory - Add
${java_type_name}
to the arguments
- 创建一个新的外部工具
- 将路径设置为 javah(在 linux 上为 /user/bin/javah)
- 将工作目录设置为
${project_loc}/bin/
bin 是您的项目输出目录 - 添加
${java_type_name}
到参数
With this setup you can call javah as external tool on any java file in the Package explorer. The generated header files currently land in the bin dir, this can be changed by adding the -d option.
通过此设置,您可以在包资源管理器中的任何 java 文件上调用 javah 作为外部工具。生成的头文件当前位于 bin 目录中,这可以通过添加 -d 选项来更改。
回答by Alexander Pogrebnyak
Here is a sample command line:
这是一个示例命令行:
javah -classpath /path/to/project/classes com.mycompany.MyClass
/path/to/project/classes - This is the 'Output folder' from the Source
tab of Java Build Path
properties page for you project.
/path/to/project/classes - 这是项目属性页面Source
选项卡中的“输出文件夹” Java Build Path
。
It may be relative to the directory from where you are running javah.
它可能与您运行 javah 的目录有关。
You may use -verbose
flag to see more details about what's going on.
您可以使用-verbose
flag 来查看有关正在发生的事情的更多详细信息。