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. [SOLVED] Execute java with Qt QProcess in Windows OS
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Execute java with Qt QProcess in Windows OS

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 7.7k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    andre
    wrote on 24 Aug 2011, 10:06 last edited by
    #2

    What is the space between the - and the jar doing in your argument?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 24 Aug 2011, 10:07 last edited by
      #3

      delete the space between the dash and jar (make "- jar" to "-jar"). And you also need to add the arguments to the switches separately:

      @
      QStringList args;
      args << "-jar" << dwnUtility.jar";
      args << "-input" << "D:\Work\Qt_prj\file1.swf";
      args << "-output" << "D:\Work\Qt_prj\file2.swf";
      args << "-quality 0.5";

      proc->start("C:\Windows\System32\java.exe", args);
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lucarma
        wrote on 24 Aug 2011, 10:08 last edited by
        #4

        isn't in code.. a cut n' paste error while writing the post :(

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on 24 Aug 2011, 10:10 last edited by
          #5

          I think you might even need to separate the quality argument into:
          @
          args << "-quality" << "0.5";
          @
          but I am not sure.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lucarma
            wrote on 24 Aug 2011, 10:13 last edited by
            #6

            ok... in this way works fine

            thanks a loot :)

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lucarma
              wrote on 24 Aug 2011, 10:15 last edited by
              #7

              bq. I think you might even need to separate the quality argument into:
              1
              args << "-quality" << "0.5";
              but I am not sure.

              Works in both manners

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on 24 Aug 2011, 10:19 last edited by
                #8

                ok, thanks. That's why I said I was not sure. Sometimes, the rules as to what goes where for argument lists for QProcess are not completely clear to me.

                Edit: I noticed this comment in the docs:
                [quote]Windows: Arguments that contain spaces are wrapped in quotes.[/quote]
                That would mean that your last argument would become wrapped in quotes if you run it on windows, and I doubt that works ok. So, for safety, I would use the two-argument form.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on 24 Aug 2011, 10:23 last edited by
                  #9

                  [quote author="Andre" date="1314181153"]ok, thanks. That's why I said I was not sure. Sometimes, the rules as to what goes where for argument lists for QProcess are not completely clear to me. [/quote]

                  As a rule of thumb:
                  Everything that you can put together into quotation marks on a shell goes into one element of the string list.

                  Something like

                  @
                  java -jar blubb.jar
                  @

                  Consists of two arguments: the "-jar" "switch" and the "blubb.jar" argument to it. If you had put it into one string like this:

                  @
                  args << "-jar blubb.jar"
                  @

                  You would have a single "switch" "-jar blubb.jar" without an argument :)

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    lucarma
                    wrote on 24 Aug 2011, 10:26 last edited by
                    #10

                    if I use

                    @args << "-jar D:\Work\Reducer\reducer.jar";@

                    i have this error msg

                    Could not create the Java virtual machine.
                    Unrecognized option: -jar D:\Work\Reducer\reducer.jar

                    but the error isn’t when use the two element separated… why?

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on 24 Aug 2011, 10:32 last edited by
                      #11

                      Because it is treated as one single argument. Actually you need two arguments (the -jar and the list of jars).

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0

                      11/11

                      24 Aug 2011, 10:32

                      • Login

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