如何从C调用Java方法++ [英] How to call Java method from C++

查看:107
本文介绍了如何从C调用Java方法++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JNI调用我的C ++与Java的功能。其中一个C ++函数的参数是 jobject THIZ (据我所知,所有的JNI本机的功能有这种说法)。该功能需要相当长时间才能完成,我想报告进度回 jobject THIZ Java对象,这样我就可以显示进度给用户。我怎么能叫jobject的方法从C ++?

I am using JNI to call my C++ function from Java. One of the C++ function's arguments is jobject thiz (as far as I know, all JNI native functions have this argument). The function takes quite long to complete and I want to report progress back to the jobject thiz Java object, so that I can show the progress to the user. How can I call jobject's methods from C++?

推荐答案

您需要看看JNI函数的GetMethodID 呼叫<类型>方法*

You need to look at the JNI functions GetMethodID and Call<type>Method*.

的各种变种的细节以及如何调用它们都记录了的 JNI规范

The details of the various variants and how to call them are documented the JNI specification.

这篇关于如何从C调用Java方法++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆