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

Make javah ignore inner classes when generating JNI headers?

Exactly what the title says. I have a class which declares certain native methods, but also has a couple of inner classes. The javah utility insists on generating separate headers for the inner classes even though they don't have any native method…
0xbe5077ed
  • 4,565
  • 6
  • 35
  • 77
2
votes
2 answers

Javah : The selected resource does not resolve to a Java element

I'm trying to create JNI headers from a Java class using javah in eclipse . I created a Program in External Tools(Run -> External Tools -> External Tools Configuraitons) with these configurations : Location :…
s4eed
  • 7,173
  • 9
  • 67
  • 104
2
votes
4 answers

Javah missing after JDK install (Linux)

I'm trying to setup Android development with Eclipse (Indigo), on Fedora17. Almost everything seems to work, just the javah is missing, to build the C headers with, for native (NDK / JNI) modules. On my windows install of the tool chain it was in…
user1847129
  • 1,010
  • 2
  • 9
  • 21
2
votes
3 answers

How to generate a specific JNI header

I have a .dll library which exports a function in the following format: _Java_folder1_folder2_folder3_JavaClassName_javamethodname@16 I cannot modify the .dll. It was given to me. I need to write a java program to call the native javamethodname.…
skyknight
  • 185
  • 2
  • 10
2
votes
1 answer

Javah cannot find khronos.opengles.GL10

There are similar questions addressed here, such as this one, but I've already checked their answers and, after implementing them, javah is still unable to find the javax.microedition.khronos.opengles.*; configuration. I have my classpath (in…
zeboidlund
  • 9,731
  • 31
  • 118
  • 180
1
vote
1 answer

Javah Error: Could not find class file for package.name

I am trying to generate C header file for JNI (Linux). I read documentation and questions on javah, but I still get the same error Error: Could not find class file for 'org.sqlite.core.NativeDB' I think I have very obvious mistake but I really…
Roman
  • 33
  • 7
1
vote
1 answer

Javah Not Recognizing class (A) mentioned in class (B) when operating on class B

I'm trying to get a jni header for class B, and class A sits in the same package, right next to it. Class B contains native functions (for which I need the JNI Header) and I use the command javah -jni ClassB -classpath (path to jarfile containing…
sparkFinder
  • 3,336
  • 10
  • 42
  • 57
1
vote
3 answers

Apache ant javah task not working with jdk 10+

We are shifting from jdk 1.8 to jdk13. In our build.xml we have
Nilesh
  • 1,047
  • 1
  • 12
  • 20
1
vote
1 answer

How to skip a javah task in ant with Java 10 and higher?

My build.xml has a javah task in it. The javah task no longer works with Java 10 and higher, so I added nativeHeaderDir to a javac task, and it is working fine. However, I still want to keep the javah task, so that the same build.xml works for older…
Rei
  • 29
  • 3
1
vote
1 answer

How do I call a Java Native Interface C function from my Go code?

I am up with implementing my Java Native Interface functions in Golang using the golang C lib. Now I want to convert a jstring to an UTF-8 string using the JNI function GetStringUTFChars but I get an error when doing it. These are the steps I have…
Rox
  • 2,647
  • 15
  • 50
  • 85
1
vote
1 answer

Android NDK: cannot launch javah

I'm trying to set javah command in External Tools in Android Studio but I get IllegalArgumentException: Not a valid class name: Files\Java\jdk1.8.0_101\jre\lib\charsets.jar;C:\Program Here are my settings in External Tools in Android…
alla
  • 529
  • 5
  • 20
1
vote
1 answer

I am trying to generate .h file in android-studio for NDK

Can anyone figure out whats the issue in this command. i used command for generating is: -classpath $Classpath$ -v -jni $FileClass$ it throws exception: Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name:…
YLS
  • 1,475
  • 2
  • 15
  • 35
1
vote
1 answer

Javah still won't find class files in OSX / Android Studio

Having referred to --> Javah error while using it in JNI ...and --> android - javah doesn't find my class ...I still can't get javah to work. Specifically... My java class is located…
Hari Honor
  • 8,677
  • 8
  • 51
  • 54
1
vote
0 answers

Trying to generate C header using javah

About a year ago I started work on a Java project which required a native C library. I used javah to generate the header file and then wrote the library. This was all done in Windows 7. Now I'm trying to revisit the project and add to the native…
SPlatten
  • 5,334
  • 11
  • 57
  • 128
1
vote
0 answers

Javah -stubs isn't generating c stub

System: I am using Windows 8.1, Eclipse Juno Service Release 2. OK, for starters I have tried compiling my project using Eclipse and that works. My class is called CConnecter and the code is: public class CConnecter { static { …
Czipperz
  • 3,268
  • 2
  • 18
  • 25