Creating a header file using JNI using 'javah'

I am trying to use JNI for an Android application using the OpenCV4Android library. I can generate the header file without using the opencv library, but I get an error when the class imports something. I guess he needs to link to the library, but I'm not sure how to do this? I am using cygwin on a Windows 8.1 64-bit machine.

original output:

$ javah -jni -classpath ./bin/classes -d jni/ com.example.icam.nativeRDE  
Error: Class org.opencv.core.Mat could not be found.

Following the tips: Android, generate jni Header Files with javah, show an error that org.opencv.core.Mat cannot find , I get the following output:

$ javah -classpath /cygdrive/c/Users/Majid/Documents/OpenCV4Android/OpenCVLib2.4.8/bin/classes/org/opencv/;/cygdrive/c/Users/Majid/Documents/OpenCV4Android/iCam/bin/classes/com/example/icam/ -jni -d jni/ com.example.icam.nativeRDE
Error: no classes specified
-bash: /cygdrive/c/Users/Majid/Documents/OpenCV4Android/iCam/bin/classes/com/example/icam/: is a directory

I tried:

  • delete '/' after icam
  • adding nativeRDE after 'icam /'
  • adding nativeRDE.class after 'icam /'

Thanks for any help.

+3
3

Javah classpath. .
: fullPackageName.className

- src, bin c\Users\Majid\Documents\OpenCV4Android\iCam\src

Javah -jni -classpath C:\ProjectName\src com.abc.YourClassName

+5

: JNI "javah"

         ***I am using Window 10 and Android Studio 2.1.2.***

, APP (JNIP ) -

      E:\test\JNIP and you wrote native methods in JniExample.java file

JDK

   C:\Program Files\Java\jdk1.8.0_51\bin> 

JNI

    E:\test\JNIP\app\src\main\JNI (where, you want to create header file)

 E:\test\JNIP\app\build\intermediates\classes\debug\com\example\mpankaj\jnip\JniExample.java

Android.jar

C:/Users/mpankaj/AppData/Local/Android/Sdk/platforms/android-23/android.jar

,

Write coommand/Terminal .h

javah -d (JNI Folder Location) -classpath (JAR Locaion);(class Location)

,

   C:/Program Files/Java/jdk1.8.0_51/bin>javah -d E:/test/JNIP/app/src/main/JNI -classpath C:/Users/mpankaj/AppData/Local/Android/Sdk/platforms/android-23/android.jar;E:\test\JNIP\app\build\intermediates\classes\debug com.example.mpankaj.jnip.JniExample 

.h com_example_mpankaj_jnip_JniExample.h

+4

javah eclipse . , . http://www.lithiumhead.com/notes/windows_jni

  • Eclipse. , WorkSpaceEclipseJNI
  • "" > "" > " Java"
  • 01Java_HelloWorld
  • "" >
  • ""
  • expand 01Java_HelloWorld
  • src "" > ""
  • com.lithiumhead.jni
  • ""
  • 01Java_HelloWorld > src  com.lithiumhead.jni "" > ""
  • HelloWorld
  • ""

HelloWorld.java

package com.lithiumhead.jni;

class HelloWorld {
 public native void sayHello();

 static {
  System.loadLibrary("HelloWorld");
}

 public static void main(String[] args) {
  HelloWorld h = new HelloWorld();
  h.sayHello();
}

}

  • "" > " " > " " ...
  • ""
  • javah - C
  • javah.exe JDK ( - C:\Program Files\Java\jdk1.7.0\Bin\javah.exe)
  • : ${project_loc}/bin/
  • -jni ${java_type_name}
  • ""
  • "".
  •  
  • ""
  • ""
  • 01Java_HelloWorld  
  • HelloWorld.java
  • "" > " " > 1 "javah" - " " C   ( C  com_lithiumhead_jni_HelloWorld.h bin  01Java_HelloWorld Java Project.)
0

All Articles