Questions tagged [javah]

javah produces C header files and C source files from a Java class. These files provide the connective glue that allow your Java and C code to interact.

javah generates C header and source files that are needed to implement native methods. The generated header and source files are used by C programs to reference an object's instance variables from native source code. The .h file contains a struct definition whose layout parallels the layout of the corresponding class. The fields in the struct correspond to instance variables in the class.

The name of the header file and the structure declared within it are derived from the name of the class. If the class passed to javah is inside a package, the package name is prepended to both the header file name and the structure name. Underscores (_) are used as name delimiters.

By default javah creates a header file for each class listed on the command line and puts the files in the current directory. Use the -stubs option to create source files. Use the -o option to concatenate the results for all listed classes into a single file.

The new native method interface, Java Native Interface (JNI), does not require header information or stub files. javah can still be used to generate native method function proptotypes needed for JNI-style native methods. javah produces JNI-style output by default, and places the result in the .h file.

87 questions
34
votes
7 answers

Javah tool error: Could not find class file for hellojni

I am trying to create a header file using javah tool from command line on windows 7 OS but i am failing all the time. I have followed different ways and even read the documentation of javah tool from oracle but they didn't help to overcome with…
S.S Sahota
  • 341
  • 1
  • 3
  • 3
17
votes
1 answer

Javah command for native methods gives Exception

I entered this into command prompt and I'm not sure why it is saying that it is not a valid class name considering that it has the position on the disk and the fully qualified class name. Java - version works and I'm running the latest version of…
Sarah Szabo
  • 10,345
  • 9
  • 37
  • 60
16
votes
2 answers

javah missing after JDK install

I can find java, javac and javadoc but there is no javah.exe in my jdk\\bin folder. I tried to reinstall the JDK but it is still missing. How can I get it, why is it missing? I found a similar question where the operating system was Linux but I can…
midudu
  • 171
  • 1
  • 1
  • 5
13
votes
5 answers

JAVAH can't find class( android ndk)

I need a help in javah and android-ndk. I tryed to generate H-file for my native method, but javah said class file not found. My target class has absolute name $PROJECT_DIRECTORY/src/bt/nativeclient/BtnativeActivity.java and contains follow…
Alex Wih
  • 1,015
  • 2
  • 11
  • 24
13
votes
3 answers

android - javah doesn't find my class

I am having troubles generating the C header file for JNI using javah. Here's the script I use while standing in the \bin directory: javah -classpath C:\PROGRA~2\Android\android-sdk\platforms\android-8\android.jar com.test.JniTest As…
KaiserJohaan
  • 9,028
  • 20
  • 112
  • 199
13
votes
1 answer

How to use javah

I've just wasted 2 hours trying to do something which I've already done twice before. I can't remember the exact procedure I used the previous two times, but it really shouldn't be giving me this much trouble: I have a project folder called…
Tagc
  • 8,736
  • 7
  • 61
  • 114
13
votes
5 answers

Javah Error android.app.Activity not found

I'm trying to create a .h header file for a simple NDK project. Using cygwin I browse to myprojectDIR\jni directory, then execute this command: javah -o com_myproject_MyActivity.h -classpath myprojectDIR\bin\classes com.myproject.MyActivity then…
Ayesh Qumhieh
  • 1,117
  • 2
  • 11
  • 26
11
votes
3 answers

Generate JNI header files for class files in JDK 10

An integral part of the Java Native Interface (JNI), is the bridging of JVM code and native code through C headers. The way to generate these header files used to be quite straight forward: simply call the command line utility javah on class files.…
Jakob Odersky
  • 1,371
  • 11
  • 23
6
votes
2 answers

Android, generate jni Header Files with javah , show error that can't find org.opencv.core.Mat

I just have an annoying problem with jni when i compile the native method in java class with javah to generate JNI header files. If the class has used 3rd-party package, For example: org.opencv.core.Mat, then the javah will show the error that…
santi
  • 117
  • 3
  • 11
5
votes
1 answer

How to create a C header file using Javah?

I am using android ndk, and for that I am trying to create a c header file using the javah tool. How to use and where to use this tool? I am unable to understand.
4
votes
1 answer

How can I pass -h argument to maven compiler plugin to create JNI header files

I already tried passing this argument in the pom but it does not recognize it. Since jdk 8 we dont have to manually run javah to generate header files rather we can pass -h argument to javac and generate the header files when compiling. So if I can…
Adiesha
  • 133
  • 2
  • 9
4
votes
1 answer

JNI: javah mangles arguments that are inner classes

I have a JNI function that passes android.graphics.Bitmap$Config as an argument. Config is an inner class of Bitmap. When I run javah I get the incorrect header signature of (truncating to just the single…
Anthony
  • 7,638
  • 3
  • 38
  • 71
4
votes
3 answers

Generate C header file (*.h) for native method implementation JNI in android studio

How to generate C header file (*.h) containing the function prototype for the native method implementation JNI in Android studio while build automatically? Thank You
ant
  • 53
  • 1
  • 6
4
votes
3 answers

Javah: Error: cannot access android.support.v7.app.ActionBarActivity

I have a problem with javah, I have read about 4 or 5 stakcoverflow posts with the error "solved" but anything works for me. My problem: When i execute the javah command i have this error: Error: cannot access…
Dan
  • 2,452
  • 20
  • 45
4
votes
2 answers

javah Android Studio Error: cannot access android.support.v7.app.ActionBarActivity class file for android.support.v7.app.ActionBarActivity not found

I am following this tutorial on how to use NDK with Android Studio: http://www.ph0b.com/android-studio-gradle-and-ndk-integration/ I have android studio 0.9.3 installled on windows 8, and i follow each step of the tutorial in the video, and at the…
wald
  • 93
  • 1
  • 2
  • 9
1
2 3 4 5 6