3

I'm running Ubuntu Linux with Eclipse installed, and I'm trying to work with JNI to do so I need to use javah, but it doesn't seem to be working I have just recently installed Ubuntu and am unfamiliar with Linux/bash shells

for my eclipse project called myJNI, I have class DoJNI containing the native method.

in Terminal:

javah -classpath .;\home\thomas\Documents\LinuxProgramming\EclipseWorkspace\myJNI\bin\org\me\jni DoJNI

errors I get are: No classes were specified on the command line

hvgotcodes
  • 118,147
  • 33
  • 203
  • 236
Prime
  • 4,081
  • 9
  • 47
  • 64

1 Answers1

6

Use forward slashes instead of backslashes, and a colon instead of a semi-colon:

javah -classpath .:/home/thomas/Documents/LinuxProgramming/EclipseWorkspace/myJNI/bin/org/me/jni DoJNI

Also, I suspect that you don't really want org/me/jni on the classpath, but just the bin directory, using the classname org.me.jni.DoJNI:

javah -classpath .:/home/thomas/Documents/LinuxProgramming/EclipseWorkspace/myJNI/bin org.me.jni.DoJNI
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • great thanks! so that generated the header file, but when I try to compile to a .so: ./org_me_jni_DoJNI.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC libnative line 0 C/C++ Problem make: *** [liblibnative.so] Error 1 libnative I'm compiling in Eclipse C/C++ – Prime Nov 15 '10 at 02:52
  • Solved it i compiled with: gcc -o nativelib.so -shared -fPIC mycode.c – Prime Nov 15 '10 at 07:01
  • Thanks a lot your answer was very useful. – Saraschandraa Jun 17 '15 at 06:43