Jni示​​例头文件未生成

时间:2013-03-25 05:33:30

标签: android java-native-interface header-files

当我运行以下命令在我的JNI项目中创建头文件时,我收到以下错误

   root@bsd-pc1907:/home/sat/KISHORE/kishore workspace/Ivijni/bin/classes/com/ivi/jni# javah JniActivity
   error: cannot access JniActivity
   bad class file: RegularFileObject[./JniActivity.class]
   class file contains wrong class: com.ivi.jni.JniActivity
   Please remove or make sure it appears in the correct subdirectory of the classpath.
   com.sun.tools.javac.util.Abort
   at com.sun.tools.javac.comp.Check.completionError(Check.java:180)
   at com.sun.tools.javadoc.DocEnv.loadClass(DocEnv.java:159)
   at com.sun.tools.javadoc.RootDocImpl.<init>(RootDocImpl.java:95)
   at com.sun.tools.javadoc.JavadocTool.getRootDocImpl(JavadocTool.java:188)
   at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:364)
   at com.sun.tools.javadoc.Start.begin(Start.java:162)
   at com.sun.tools.javadoc.Main.execute(Main.java:113)
   at com.sun.tools.javah.Main.main(Main.java:153)
    javadoc: error - fatal error
  2 errors

我的JniActivity.java

public class JniActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    System.loadLibrary("hellojni");
    new JniActivity().sayHello();

}
private native void sayHello();

}

hellojni.cpp

 #include "hellojni.h"
 #include  <iostream>

 using namespace std;

 void sayHello () {
 cout << "Hello World Again!" << endl;
 return;
 }

我们非常感谢任何帮助,谢谢

1 个答案:

答案 0 :(得分:0)

  

root @ bsd-pc1907:/ home / sat / KISHORE / kishore workspace / Ivijni / bin / classes / com / ivi / jni #javah JniActivity

这里有几个问题。

  1. 你在错误的目录中。你应该在/home/sat/KISHORE/kishore workspace/Ivijni/bin/classes
  2. 您发出了错误的命令。 javah的参数,javaprmic以及处理.class文件的所有其他Java实用程序,是一个完全限定的类名,包括包名。你没有提供,所以你得到错误。