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 的类文件
基础教程推荐
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Struts2 URL 无法访问 2022-01-01
