When Java uses JNI, it uses the header file of Javah genetic. h, but the file is not found with an error.
You may open the directory, clearly see a class file is the error can not find the file, because Javah to find the class package name first. What does that mean.
On the source code bar.
If you have one of these Java classes:
public class hello{public
static native string init (string Umi);
}
Note that this class does not have a package name, then you want to javah generate. h file, the direct shell or command prompt to the Java class in the directory, with Javac Hello.java into class files, You can see a hello.class file, then you can javah hello to generate. h files. The generated. h file is in the current directory, which is the directory where the class file resides.
If this class has a package name, such as:
Com.company.helloworldproject.Class
public class hello{public
static native string init (string Umi);
}
Well, the complete directory of this class is almost here: D:\my\app\src\main\java\com\company\helloworldproject\Class, (Take this directory for example) when the shell or command prompt comes to your project's folder Java directory, run the Javah package name. Class name is Javah Com.company.helloworlproject.class.hello can directly generate the. h file, do not need to javac into class file.
Summary: Javah generation. h file, if your Java class is a package name, should not go to the directory where the class files run the Javah command, but should be in the package name of the previous directory run, that is, run: Javah Package name + class name. class, generated. h files in the Java directory.
If the Java class is not a package name, Javah runs directly in the directory where the shell is located in the class file: Javah class name. class.