“The command ‘javac -h’ and ‘javah -jni’ can’t find the file I specified.”

huangapple go评论84阅读模式
英文:

The command "javac -h" and "javah -jni" can't find the file I specified

问题

我正尝试使用命令 javah -jni MyClass.java 生成头文件(MyClass.h),因为我使用的是 JDK 1.8,但我还尝试了使用另一个版本的命令 javac -h MyClass.java,但我在终端中始终得到以下结果:
“The command ‘javac -h’ and ‘javah -jni’ can’t find the file I specified.”

我所有的 .java 或 .class 文件都在这个文件夹中。

谢谢帮助
[编辑] 我还尝试了使用 .class 文件,但是使用 javac -h 得到的输出与上述相同,但是使用 javah -jni 得到以下输出:
“The command ‘javac -h’ and ‘javah -jni’ can’t find the file I specified.”

英文:

I'm trying to generate the header file (MyClass.h) using the command javah -jni MyClass.java since I use the JDK 1.8 but I also tried with the other version of the command javac -h MyClass.java but I always get the following result in my terminal :
“The command ‘javac -h’ and ‘javah -jni’ can’t find the file I specified.”

All my .java or .class file are in this folder.

Thank you for the help
[edit] I also tried with the .class file but the output is the same with javac -h but with javah -jni I get the following output :
“The command ‘javac -h’ and ‘javah -jni’ can’t find the file I specified.”

答案1

得分: 1

尝试先编译SimpleJNI.java文件,然后执行javah命令。

示例类:

public class SimpleJNI
{
   public static void someMethod()
   {
      System.out.println("Some method");
   }
}

使用javac进行编译,如果有外部依赖,请使用-classpath参数。

javac -classpath <path_to_dependency> SimpleJNI.java

如果没有依赖,可以不加-classpath参数。

javac SimpleJNI.java

然后使用javah命令针对你的.class文件执行:

javah SimpleJNI
英文:

Try to compile SimpleJNI.java first and then execute javah command.

Sample class

public class SimpleJNI
{
   public static void someMethod()
   {
      System.out.println(&quot;Some method&quot;);
   }
}

Compile is using javac with -classpath if there is any external dependency required.

javac -classpath &lt;path_to_dependency&gt; SimpleJNI.java 

or without -classpath if there is no dependency

javac SimpleJNI.java

then execute javah with your .class file

javah SimpleJNI

huangapple
  • 本文由 发表于 2020年10月14日 14:48:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/64347974.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定