Android開發:javah的使用方法

通過javah可以自動生成相應的JNI的.h文件,運行“javah -help” 命令顯示用法如下:

  1. Z:\>javah -help 
  2. Usage: javah [options] <classes> 
  3.  
  4. where [options] include: 
  5.  
  6.         -help                 Print this help message and exit 
  7.         -classpath <path>     Path from which to load classes 
  8.         -bootclasspath <path> Path from which to load bootstrap classes 
  9.         -d <dir>              Output directory 
  10.         -o <file>             Output file (only one of -d or -o may be used) 
  11.         -jni                  Generate JNI-style header file (default
  12.         -version              Print version information 
  13.         -verbose              Enable verbose output 
  14.         -force                Always write output files 
  15.  
  16. <classes> are specified with their fully qualified names (for instance, java.lang.Object). 

 

example:
 
hello-jni應用程序所在目錄爲F:\hello-jni, 編譯生成的class文件在bin\classes文件夾下,那麼調用javah時的classpath 必須指向該路徑
 
第一種情況:
F:\hello-jni>javah -classpath bin/classes com.example.hellojni.HelloJni 
在應用程序根目錄下,那麼classpath 的相對路徑爲 bin/classes
 
第二種情況:
F:\hello-jni\bin>javah -classpath classes com.example.hellojni.HelloJni
在bin目錄下,那麼classpath的相對路徑爲 classes
 
第三種情況:
F:\hello-jni\bin\classes>javah -classpath . com.example.hellojni.HelloJni
在classes目錄下,那麼classpath應該爲當前目錄,即 .
 
第四種情況:
F:\temp>javah -classpath F:\hello-jni\bin\classes  com.example.hellojni.HelloJni
此時classpath 應該指向classes所在的絕對路徑,即F:\hello-jni\bin\classes 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章