To compile the class file command in javac, note that when importing Class A in Class B, it must include the path of a when compiling Class B, such
Project SRC com. Jl. Test A. Java
Com. Jl. Test2 B. Java
In B, importa should be: javac-CP ~ /Project/src B. Java (-CP: classpath for short, to ensure ~ Under/project/src, you can find the import com. Jl. test. ;)(~ /Project/src is a relative path, which is a relative path in Linux, and an absolute path can be written in windows, such as D:/project/src)
Javah compiles the class file into a. h file to ensure that the file contains the native method, mainly to complete the so file compiled.
Run javah-JNI com. Jl. test2. B in the directory "com" out of SRC or out of your package name. (class file is automatically found by default without the class extension)
OK
Java_com_jl_test2_ B .h is generated outside the com path.
If this command still reports that the class file cannot be found, you can try javah-classpath.-JNI com. Jl. test3. B to generate the. h file.
If an error is reported when a third-party package is imported during compilation, you can comment out the error file before compiling.