4

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.

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 <QAndroidJNIObject>. Commented Feb 22, 2015 at 6:31
  • You are right. It was my mistake. Commented Feb 22, 2015 at 6:31
  • 1
    You should use JNI. It's kind of related to c++ not Qt. See : stackoverflow.com/questions/819536/… Commented Feb 22, 2015 at 6:47
  • 2
    But Qt now offers abstraction for it, and when using Qt, it is usually better to do things the "Qt way" stackoverflow.com/questions/27094100/… Commented Apr 17, 2015 at 15:07

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.