쓰라고 주는 툴을 못 쓸때..

정말 자괴감에 빠집니다… 으으으으………….

JNI라는 걸 좀 해보려고 javah 라는 header 파일 생성기를 좀 써보려고 노력중이었습니다.

근데 아무리 쓰여진데로

javah -classpath ../../android.jar;../bin/classes; org.apache.NativeAdd

를 쳐도 안되는 겁니다.

1. 경로명이 잘못됐나?
2. 경로명을 따옴표로 묶어주어야 하나?
2. 클래스 파일을 잘못 만들었나?
3. android.jar하고 뭔가 관련이 있나?
4. access 할 수 없다니.. 권한 문제인가..
5. 파일을 왜 못찾는다지?
……

결국 원인은 무엇인고 하니..

javah의 -verbose 옵션을 켰더니 다음과 같이 나오는군요.

dasomoli@dasomoli-ubuntu804:~/CallNative/src$ javah -classpath “../../android.jar;../bin/classes;” -verbose org.apache.NativeAdd
error: cannot access org.apache.NativeAdd
class file for org.apache.NativeAdd not found
javadoc: error – Class org.apache.NativeAdd not found.
[
Search Path:
/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/classes/../../android.jar;../bin/classes;
]

Error: No classes were specified on the command line.  Try -help.

아시겠습니까?

네.. 그렇습니다. ‘;’ 대신 ‘:’를 써주어야 하는 겁니다.

이렇게 해주어야 되는 것이었습니다.

javah -classpath ../../android.jar:../bin/classes: org.apache.NativeAdd

그래서 결과는 다음과 같이 나옵니다.

dasomoli@dasomoli-ubuntu804:~/CallNative/src$ javah -classpath “../../android.jar:../bin/classes:” -verbose org.apache.NativeAdd
[ Search Path: /usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.06/jre/classes/../../android.jar:../bin/classes: ]
[Creating file org_apache_NativeAdd.h]
[search path for source files: ../../android.jar,../bin/classes,.]
[search path for class files: /usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/resources.jar,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/rt.jar,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/sunrsasign.jar,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/jsse.jar,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/jce.jar,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/charsets.jar,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/classes,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/ext/dnsns.jar,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/ext/sunpkcs11.jar,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/ext/localedata.jar,/usr/lib/jvm/java-6-sun-1.6.0.06/jre/lib/ext/sunjce_provider.jar,../../android.jar,../bin/classes,.]
[loading ../bin/classes/org/apache/NativeAdd.class]
[loading java/lang/Object.class(java/lang:Object.class)]
[loading java/lang/Throwable.class(java/lang:Throwable.class)]
[loading java/lang/Class.class(java/lang:Class.class)]
[done in 717 ms]

이럴 때… 정말 자괴감에 빠집니다..ㅠㅠ