Correctly Use the javah command to generate the JNI header file

Source: Internet
Author: User

I read a lot about how to use the javah command on the Internet, but none of them are correct. I tried it a few days ago and finally got it done. The main JDK version is jdk1.7.0 _ 21. The usage is as follows:

1. declare that the java_home environment variable is c: \ Program Files \ Java \ jdk1.7.0 _ 21 The java_home environment variable may be Program So it is better to declare it separately. JDK main directory 2. Add the % java_home % \ bin directory to the path. This setting allows the system to find the javah execution File 3. Set the classpath environment variable. This variable is automatically searched during javah execution. Although you can set it manually each time, it is better to set it as an environment variable .. Indicates the current directory. 4. Compile an android project in Android This project is used as an example to organize documents

The native function is declared in the nativesurf class.

The compiled class file is located in copy of opencv \ bin \ Classes.

Note: when using the native method, you must create a separate package and Class. Do not add other classes. Otherwise, the system will prompt that the class cannot be found.
5. Open the command prompt in the copy of opencv \ bin \ Classes directory and use javah <package name. Complete Class Name> to generate a native. h file under classes.

The generated header file is organized as follows:



The header file is successfully generated.

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.