hi all is it possible to declare to native methods in java so that one method is defined in c and other method is defined in c++.m getting confusion in it . please help me in this.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. As long as the interface uses the standard C calling convention, Java doesn’t really care in which language it’s implemented. That means you have to surround the declarations in an
extern "C"block if you happen to be writing C++:It’s up to you whether to implement
MyNativeMethodin C, C++ or any other language.Of course, this is already done for you in the header file generated by
javah,extern "C"and all.