The class file 'xx. XXXX. XX. classname' cannot be found in the misunderstanding of how to use Javah to generate C/C ++ header files. gcc cannot find the header file.

Source: Internet
Author: User

The class file 'xx. XXXX. XX. classname' cannot be found in the misunderstanding of how to use Javah to generate C/C ++ header files. gcc cannot find the header file.

PS: Recently, jni is used. It may be a headache to write c ++ in java later. When using javah, I encountered a small problem and shared it with you.

Javah is a great tool, which can be obtained through. class file, and generate the corresponding C ++ file, which contains the JNI stubs of all local methods in java code, that is, the methods defined as native. If you are using a JNI stub of a class and you have defined this class as a part of the package, you must fully define the class name. It seems that javah is like a decompilation tool. Well, that's it.


For example, I compile a java file using eclipse, and then compile and generate a file using eclipse. class file, under the bin directory, So I decisively enter my folder, XX/XXXX/XXX contains my. class file, so I followed the instructions, javah-jni XX. XXXX. XX. class Name. In the result, he prompts that I cannot find 'xx. XXXX. XX. class file. :


So I exited to the bin directory and re-entered the command to get the same answer!

After finding the answer, make sure that the directory is the top-level path of the java package. If it is compiled by eclipse, it is under the bin directory and instructions are used.

javah -classpath . XX.XXXX.XXX.CLASSNAME

That's it !! Note that there is a separate decimal point in the middle! Then you can get the. h file you 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.