Javah tool error: Could not find class file for hellojni(Javah 工具错误:找不到 hellojni 的类文件)
问题描述
我正在尝试使用 javah 工具从 Windows 7 操作系统的命令行创建一个头文件,但我一直都失败了.
I am trying to create a header file using javah tool from command line on windows 7 OS but i am failing all the time.
我遵循了不同的方法,甚至从 oracle 阅读了 javah 工具的文档,但它们无助于克服这个问题.
I have followed different ways and even read the documentation of javah tool from oracle but they didn't help to overcome with this problem.
我的类文件(hellojni.class
)和java文件(hellojni.java
)都在D:
驱动器的根目录下.
My class file (hellojni.class
) and java file (hellojni.java
) both are in the root of D:
drive.
但是每当我运行 javah 工具时,它都会给我一个错误:
But whenever I run javah tool it gives me an error:
找不到 hellojni 的类文件
could not find class file for hellojni
我也尝试提供类路径,但没有得到任何头文件.
I tried by providing classpath as well but not getting any header file.
推荐答案
我怀疑问题是你的类有一个包,你试图从包含类文件而不是包的目录中运行命令根.
Samhain 的示例有效,因为他的 MyClass.java
不包含包,而我怀疑你的包含.
Samhain's example works because his MyClass.java
contains no package, whereas I suspect yours does.
例如,假设我们在 c:srccomexampleMyClass.java
package com.example;
public class MyClass {
public native void myMethod();
}
转到命令行并执行以下命令:
Go to the command line and execute the following:
c:srccomexample>javac MyClass.java
c:srccomexample>dir
Directory of C:srccomexample
2015-02-23 03:17 PM <DIR> .
2015-02-23 03:17 PM <DIR> ..
2015-02-23 03:20 PM 219 MyClass.class
2015-02-23 03:17 PM 84 MyClass.java
c:srccomexample>javah MyClass
Error: Could not find class file for 'MyClass'.
c:srccomexample>cd c:src
c:src>javah com.example.MyClass
c:src>dir
Directory of C:src
2015-02-23 03:18 PM <DIR> .
2015-02-23 03:18 PM <DIR> ..
2015-02-23 03:16 PM <DIR> com
2015-02-23 03:18 PM 449 com_example_MyClass.h
成功了!
这篇关于Javah 工具错误:找不到 hellojni 的类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Javah 工具错误:找不到 hellojni 的类文件


- 未找到/usr/local/lib 中的库 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 获取数字的最后一位 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 转换 ldap 日期 2022-01-01