以下のコマンドを実行して 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;
}
どんな助けでも大歓迎です、ありがとう