如何在Eclipse中配置javah工具[英] How to configure javah tool in Eclipse

本文是小编为大家收集整理的关于如何在Eclipse中配置javah工具的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我已经找到了大约5个答案,尝试了所有答案,但没有使其工作.

env:ubuntu 12.04/indigo

run->外部工具 - >外部工具配置...

创建了新程序 位置:/usr/bin/javah/* $ javah给予/usr/bin/javah */

工作目录:$ {workspace_loc:/myproject/bin/class}

属性:-d $ {workspace_loc:/myproject/jni} com.myproject.myactivity

运行的结果:找不到'com.myproject.myactivity'

的类文件

从终端运行给出相同的结果 maxim@ubuntu:〜/workspace/myproject/bin/class $ javah -jni com.myproject.myactivity

错误:无法访问android.app.Activity android.app.Activity找不到的类文件 maxim@ubuntu:〜/workspace/myproject/bin/class $

SDK/NDK已安装,添加了外部路径. 如何添加丢失的零件?谢谢大家.

7月3日编辑

将本机LIB加载到单独的类解决问题

推荐答案

我在Linux上也有非常相似的问题.事实证明我没有在正确的文件夹上进行.

尝试阅读它,看看它是否有帮助:在Linux上使用Javah .

其他推荐答案

android开发人员的答案中也提到了这篇文章 :

您可以通过下面的屏幕截图看到,设置了这样的外部工具:

  1. 在Eclipse ADT中,单击菜单的最后一个选项上的"运行","外部工具",然后选择"外部工具配置"

  2. 将路径设置为以下内容:

    2.1.位置:无论您在哪里安装Java c:\ program文件\ java \ jdk1.7.0_13 \ bin \ javah.exe

    2.2.工作目录:您的项目/bin/class/目录 $ {workspace_loc:/myproject/bin/class}

    2.3.参数: -jni $ {java_type_name}

  3. 单击运行(请注意,您必须选择Java类)

  4. 使用您的文件浏览器,检查/bin/class/directory-您应该在此处找到.h标头文件.

在此处输入图像说明

希望这对某人有帮助.

其他推荐答案

基于Enke的答案,我为方便添加了更多论点.
1.您不必使用" -ClassPath"正确设置DIR. 2.您可以从Eclipse中的Integrated Console获取详细信息.
3.您可以使用" -D"参数指定输出DIR.
*不要忘记在此图片中替换项目目录名称.(" myproject")

如何设置Eclipse项目中的Javah执行参数.

>

本文地址:https://www.itbaoku.cn/post/102628.html

问题描述

I found already about 5 answers, tried all of them and didn't get it working.

Env: Ubuntu 12.04/ Indigo

Run->External Tools->External Tools Configuration...

Created new Program Location: /usr/bin/javah /*$ which javah gives /usr/bin/javah */

Working directory: ${workspace_loc:/MyProject/bin/classes}

Attributes: -d ${workspace_loc:/MyProject/jni} com.myproject.MyActivity

Result of RUN: Could not find class file for 'com.myproject.MyActivity'

Run from terminal gives same result maxim@ubuntu:~/workspace/MyProject/bin/classes$ javah -jni com.myproject.MyActivity

Error: cannot access android.app.Activity class file for android.app.Activity not found maxim@ubuntu:~/workspace/MyProject/bin/classes$

SDK/NDK installed, external paths added. How to add missing parts? Thanks everybody.

Edited Jul 3

Moving native lib loading to a separate class solved the problem

推荐答案

I had a very similar problem on linux too . it turned out that i didn't do it on the right folder.

Try to read it and see if it helps: Using javah on linux.

其他推荐答案

Elaborating on this post also mentioned in android developer's answer:

As you can see by the screen shot below, set up the external tools like this:

  1. In the Eclipse ADT, click on "Run", hover on the last option of the menu - "External Tools" and choose "External Tools Configurations"

  2. Set the paths up to the following:

    2.1. Location: wherever you installed Java C:\Program Files\Java\jdk1.7.0_13\bin\javah.exe

    2.2. Working Directory: your project's /bin/classes/ directory ${workspace_loc:/MyProject/bin/classes}

    2.3. Arguments: -jni ${java_type_name}

  3. Click on run (note that you have to have the java class selected)

  4. Using your file browser, check the /bin/classes/ directory - you should find the .h header file there.

enter image description here

Hope this helps someone.

其他推荐答案

Based on Enke's answer I added more argument for convenience.
1.You don't have to set working dir correctly by using "-classpath ".(You can ignore the working dir setting in the pic.)
2.You can get verbose info from integrated console in Eclipse.
3.You can specify output dir by using "-d " parameter.
*Don't forget to replace the project directory name in this pic.("MyProject")

How to set JavaH execution parameter in Eclipse project.