[SOLVED] Execute java with Qt QProcess in Windows OS
-
What is the space between the - and the jar doing in your argument?
-
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);
@ -
isn't in code.. a cut n' paste error while writing the post :(
-
I think you might even need to separate the quality argument into:
@
args << "-quality" << "0.5";
@
but I am not sure. -
ok... in this way works fine
thanks a loot :)
-
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
-
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. -
[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 :)
-
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.jarbut the error isn’t when use the two element separated… why?
-
Because it is treated as one single argument. Actually you need two arguments (the -jar and the list of jars).