Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Running jar files in Qt creator
QtWS25 Last Chance

Running jar files in Qt creator

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 5.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mansi
    wrote on 9 Oct 2013, 08:16 last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      butterface
      wrote on 9 Oct 2013, 09:23 last edited by
      #2

      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.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        p3c0
        Moderators
        wrote on 9 Oct 2013, 09:27 last edited by
        #3

        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.

        157

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p3c0
          Moderators
          wrote on 9 Oct 2013, 09:38 last edited by
          #4

          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.

          157

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mansi
            wrote on 10 Oct 2013, 03:47 last edited by
            #5

            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...

            1 Reply Last reply
            0
            • P Offline
              P Offline
              p3c0
              Moderators
              wrote on 10 Oct 2013, 05:08 last edited by
              #6

              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.

              157

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mansi
                wrote on 10 Oct 2013, 08:04 last edited by
                #7

                yes I did... I am trying to run that in my Qt creator.Throwing a lot of errors like "/home/manasi/Downloads/untitled7/androidmediaplayer.cpp:18: error: invalid conversion from 'JNIEnv** {aka JNIEnv_}' to 'void' [-fpermissive]"

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mansi
                  wrote on 11 Oct 2013, 08:18 last edited by
                  #8

                  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 :)

                  Z 1 Reply Last reply 1 Aug 2017, 20:47
                  0
                  • M mansi
                    11 Oct 2013, 08:18

                    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 :)

                    Z Offline
                    Z Offline
                    zabdielfer
                    wrote on 1 Aug 2017, 20:47 last edited by
                    #9

                    @mansi
                    wich is version of Qt you are using?
                    this to know version Qt that I will must be to work

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved