Is it possible to call java function from Qt Application and if so, how? Do I need to update java source for such task? I have Qt Desktop Opensource edition.
Asked
Active
Viewed 3,033 times
4
-
@Nejat, I have Qt Desktop edition, version 5.4 Opensource, do not have `QAndroidJNIObject` available I think; QtCreater does not find it if I do `#include
`. – KernelPanic Feb 22 '15 at 06:31 -
You are right. It was my mistake. – Nejat Feb 22 '15 at 06:31
-
1You should use JNI. It's kind of related to c++ not Qt. See : http://stackoverflow.com/questions/819536/how-to-call-java-function-from-c – Nejat Feb 22 '15 at 06:47
-
2But Qt now offers abstraction for it, and when using Qt, it is usually better to do things the "Qt way" http://stackoverflow.com/questions/27094100/how-to-use-qandroidjniobject-to-call-java-code-from-inside-qt/27095161#27095161 – dtech Apr 17 '15 at 15:07
1 Answers
2
First of all think twice before calling java from C/C++. For Android it allow you call some API function of OS, but you pay with perfomance and some hard catching errors.
Qt designed pretty easy way for calling Java: package - androidextra But if you need call it on desktop there is a way to avoid it: JNI(as Nejat says).
Here is simple example of using it: http://www.codeproject.com/Articles/22881/How-to-Call-Java-Functions-from-C-Using-JNI

POTEMKINDX
- 395
- 2
- 9