Running jar files in Qt creator
-
Hello guys,
I want to code in java in Qt creator. Is it possible ?
I have compiled a simple hello world program in the terminal, that displays helloworld in the terminal.
I have got a class file and put that class file in the .jar folder which I have created.
How do I run that jar folder in Qt creator ?? Can it be done ??
I have read that it can be done using jni.h.
Can you please help me ? -
Writing Java programs in the Qt Creator is for sure not the best way to do that. It is designed to support you writing C/C++ programs and that's it.
Maybe you should consider using Eclipse or there are some light weight IDE's for that as well.You can also write plugins which enable you to do what ever you want but I am not sure if it is worth to do that work.
-
I guess you normally run jar files using command "java -jar jarfilename". So you can use QProcess to run the java command and pass the remaining as the arguments.
-
Also there are these examples "JNI":https://groups.google.com/forum/#!msg/android-qt/MesA5b2Bpv0/S1EmaNZP28IJ and "Necessitas-JNI":http://community.kde.org/Necessitas/JNI. But they are calling java code and not jar files.
-
I was able to execute the jar files from my C++ code.
Now if I have to call java functions from C++, I assume I wil have to use jni.
I couldnt find any appropriate example for this...
If anybody has done this, could you please share your piece of code with me because I am trying this from past few days and wasn't successful in calling a java function from C++.
Any help will be appreciated :)
Thanks a lot in advance... -
Hi mansi,
Did you see the two links that have been provided above ? It clearly has example for JNI. The "Necessitas-JNI":http://community.kde.org/Necessitas/JNI. has sample code.
-
Hello,
I was able to call java method from my C++ code successfully.
Referred this link "http://www.ibm.com/developerworks/java/tutorials/j-jni/section3.html".
With few changes in the code was able to execute it :)
Thanks a lot :) -
Hello,
I was able to call java method from my C++ code successfully.
Referred this link "http://www.ibm.com/developerworks/java/tutorials/j-jni/section3.html".
With few changes in the code was able to execute it :)
Thanks a lot :)@mansi
wich is version of Qt you are using?
this to know version Qt that I will must be to work