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
1
vote
0 answers

How do you configure m2e/Maven to generate JNI/C++ classes?

Short overview: My situation What I want What I have done so far 1. My situation: In my company we use a document archiving software called Proxess. This software offers several APIs / interfaces to interact with. The only backdraw is that they…
Crazy Bytes
  • 69
  • 1
  • 1
  • 11
1
vote
2 answers

Can javah be coaxed to generate .h files with consistent line endings?

I have a maven project that generates .h JNI files by executing javah as part of the normal build process of a java library. These .h files are then checked in to source control (such as git) and used to build the accompanying native library. One…
cambecc
  • 4,083
  • 1
  • 23
  • 24
1
vote
1 answer

Android and Javah in Eclipse

I want to generate headers file for my Android NDK app but I have some problem with it. I use external tools configuration in eclipse but I get error: Error: Could not find class file for 'com.myapp.MainActivity'. In attachment I enclose screens…
AYMADA
  • 889
  • 3
  • 17
  • 37
1
vote
2 answers

Javah missing android.os.Parcelable

When I'm trying to create a headerfile with javah I get an error that he can't find the Parcelable class. Before I created the header with: From %PROJECTDIR%/bin/classes/ javah -classpath com.my.project But now I added the Parcelable to the native…
Ion Aalbers
  • 7,830
  • 3
  • 37
  • 50
0
votes
1 answer

classpath in javah

I'm realy in desperation. I looked up all answeres regarding javah but could not get a solution. I tried: javah -jni com.aegisguitest.testrobot.recognition.SpyDotNET The environment variable CLASSPATH is set to the right directory: C:\users\Marcus…
Marcus Tik
  • 1,709
  • 6
  • 20
  • 30
0
votes
0 answers

javah checks sources modification time since JDK 7

I have this trivial source code. I build it with JDK 6. The build goes fine with JDK 6 and produces two build artifacts: ./Class_B.class and subdir/Class_A.class. public class Class_B extends Class_A {} (File ./Class_B.java) public class Class_A {} …
Alexander Samoylov
  • 2,358
  • 2
  • 25
  • 28
0
votes
1 answer

The command "javac -h" and "javah -jni" can't find the file I specified

I'm trying to generate the header file (MyClass.h) using the command javah -jni MyClass.java since I use the JDK 1.8 but I also tried with the other version of the command javac -h MyClass.java but I always get the following result in my terminal…
J.erome
  • 688
  • 7
  • 26
0
votes
1 answer

How to generate struct definition in the JNI header file with the javac or javah commands?

Given a class such as: class Position { float x; float y; public static native long instance(); public static native float getX(long ptr); public static native float getY(long ptr); public static native long delete(long…
Vlad Radu
  • 1
  • 1
0
votes
0 answers

javah 'Could not find class file' for mulitple paths

I have a class file with a native method on a path while its dependencies live on a separate path in a different package. My tree looks something like: [build/classes]$ tree -L 3 . ├── main │ └── com │ └── foo └── test └── com …
user2183336
  • 706
  • 8
  • 19
0
votes
0 answers

How to configure external tools for Javac in eclipse

I have a problem. I want to run a programm in java that is written in C++. For that purpose I have to create headerfiles and to compile. I watched several tutorials. They all just telling me to type in that and click on button and the file is…
G S
  • 7
  • 4
0
votes
1 answer

How to fix "UnsatisfiedLinkError: No implementation found" error using jni and javah

I want to use C++ method inside my Java code. So I decided to use JNI. But the link seams to not work properly, du to my error at the execution No implementation found for void com.me.Native.helloWorld() (tried Java_com_me_Native_helloWorld and…
Jérémy
  • 1,790
  • 1
  • 24
  • 40
0
votes
3 answers

Why is CLASSPATH prefixed with JDK path?

While trying to build a library that uses javah, I ran into a classpath issue. Apparently, the classpath is prefixed with the JDK path: please notice the final search path is wrong. How should I do instead? elmarco@makai:~/src/sasl/java/CyrusSasl…
elmarco
  • 31,633
  • 21
  • 64
  • 68
0
votes
1 answer

Javah tool error: could not find class file for HelloWorld

I am trying to create a header file using javah tool from the command line and an external tool configuration on eclipse on windows 7 OS but it's not working. My code is: package mypackage; public class HelloWorld { private static String…
0
votes
1 answer

javah -jni not working?

I've been trying to create a .h file with the command : javah -jni MyClass of course after doing javac MyClass.java which doesn't give me any error messages... However whenever I execute the javah -jni command I get the following error: Exception…
AlexT
  • 589
  • 2
  • 9
  • 23
0
votes
1 answer

Any examples on how to generate .h JNI files by executing javah within Maven POM

I can accomplish this via command line, but am trying to use Maven and the POM to automate the creation of a .h file. I am quite lost - has anybody accomplished this feat. Any clues would be extremely helpful.
Tim
  • 41
  • 4