Java JNI javac javah Compilation

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.