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
4
votes
1 answer

Android NDK - Include a c++ header in a different header?

I have an Ability.h file that is dependent on an Effect.h file. I need to use javah to generate my header, but I'm unable to define an Effect dependency in my Ability.java class from which I'd like the c++ header to be generated. Example: public…
ScarletAmaranth
  • 5,065
  • 2
  • 23
  • 34
3
votes
0 answers

How to use javac -h?

The new feature of java 10, which removed javah, instead providing javac -h. But when I tried this, it said "No source file". I try to add source file name, class file name, class file name(no suffix), dir name, ... in tail, but it's no use. And I…
Hugo Pual
  • 31
  • 1
3
votes
1 answer

How to fix 'javah' error to create JNI folder when using NDK with Android Studio?

I Create a WebCam based Android Application. I follow a YouTube video to create JNI to support my project. But i will show error on creating a JNI folder in parent directory. When i compile the code in…
3
votes
3 answers

Generating header file with JNI using 'javah'

I'm trying to use JNI for an Android application using the OpenCV4Android library. I can generate a header file without using the opencv library, but I get an error whenever the class imports anything. I assume it needs to link to the library, but…
user3019612
  • 259
  • 2
  • 7
  • 15
3
votes
1 answer

easiest way to generate files in jni folder android

I am wondered if there is a way to generate the .h files in the jni folder easier than command like this javah -jni -classpath bin/classes/ -d jni/ com.example.test_ndk.FibLib I mean I want to automate this step so I have to write only public…
3
votes
1 answer

"Can't load javah" error in Eclipse

I am trying to use the javah task in an ant build file in Eclipse and I keep getting the following error: BUILD FAILED C:\sandbox\build-jni.xml:7: Can't load javah Here is my build-jni.xml file:
3
votes
2 answers

javah issue Android Ndk in Linux

I am using Ubuntu Linux 32bit system, in terminal it shows no class specified sanidhya09@sanidhya09:~/workspace/NdkFooActivity$ javah -jni -classpath adt-bundle-linux-x86/sdk/platforms/android-4.2/android.jar;bin/classes/ -d jni/…
Sanidhya Kumar
  • 714
  • 1
  • 6
  • 18
3
votes
1 answer

Is there a way to make sure a C++ .h matches the corresponding C++ .cpp file?

The code in question is a JNI interface between a Java and a native code. The h file is produced by the javah utility, whereas the cpp file is created by human. If the Java part is renamed then javah produces function prototypes with the…
mark
  • 59,016
  • 79
  • 296
  • 580
3
votes
4 answers

javah error : cannot access activity

I was trying to make a .h file using Javah for my Android NDK application.I am using cygwin to do the same for me. Fixing the workspace to bin folder of my current application, I executed this command :- javah -classpath…
Prashant Singh
  • 3,725
  • 12
  • 62
  • 106
3
votes
2 answers

Using javah on linux

I have a simple class for use on JNI, which i need to export to a header file (.h). I've read that I need to use the javah command, by going to the src folder of the project, and type: javah -jni com.main_package.NativeClass On windows it works…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
2
votes
1 answer

Why does javah need the bytecode to generate JNI headers?

This is a question which puzzles me. javah needs a classpath, of bytecode-compiled classes, in order to generate its headers. But there is javac which, presumably, builds an AST out of the source code, which could possibly be used by javah as well.…
fge
  • 119,121
  • 33
  • 254
  • 329
2
votes
1 answer

Android Studio Native Development: Javah input parameters

I've been trying to get Native Development off the ground today in Android Studio. I think I have everything set up correctly, except for javah. When trying to run it I get thrown the error "Exception in thread "main"…
2
votes
1 answer

collect2.exe: error: ld returned 1 exit status while compiling C++ code with gradle 2.3

Below is the system configuration where I am running my gradle script to compile my c++ code System Configuration: Windows: Server 2012 R2 Standard System Type: 64-bit Operating System Java jdk1.7.0_40 MinGw x86_64-5.1.0-posix-seh-rt_v4-rev0…
unknown
  • 1,815
  • 3
  • 26
  • 51
2
votes
1 answer

Javah and Eclipse missing class files (android.support.v4.app.FragmentActivity)

I want to generate headers using javah but when i do i get an error: Error: cannot access android.support.v4.app.FragmentActivity class file for android.support.v4.app.FragmentActivity not found I created new External Tool with this…
2
votes
1 answer

Android NDK: JavaH cannot find signature for Bitmap

I have a native method in my Android Class as: public native void decode(Bitmap pTarget, byte[] pSource); When I try to create the header file using Eclipse Javah tool from Externla Configuration tools, I get a message that says: Error: Cannot…
sireesha
  • 147
  • 1
  • 5
  • 16