Hi. I'm writing a windows application using Qt (4.6.1) that uses QProcess class to execute a java application.
Here's basically the code:
process = new QProcess(this);
connect( process, SIGNAL( started() ), this, SLOT( onProcessStarts() ) );
connect( process, SIGNAL( finished(int) ), this, SLOT( onProcessEnds(int) ) );
connect( process, SIGNAL( readyReadStandardOutput() ), this, SLOT( onProcessOutputs() ) );
connect( process, SIGNAL( error(QProcess::ProcessError)), this, SLOT(onProcessError(QProcess::ProcessError)));
QStringList arguments;
arguments << "-jar";
arguments << "absolute_path\app.jar"; //the java app that I want to execute
arguments << "-blah-blah"; //some java app's arguments
process->start( "java", arguments );
This is how I start the java application, and it works ok BUT, as far as I tested only in my Windows XP machine. When I tested this on another computer with Windows 7, it failed.
In Windows 7, the QProcess signal error(QProcess::ProcessError) is emitted after process->start(...) giving me the error QProcess::FailedToStart
Also I tested this: QStringList arguments; arguments << "/c"; arguments << "java"; arguments << "-jar"; arguments << "absolute_path\app.jar"; //the java app that I want to execute arguments << "-blah-blah"; //some java app's arguments process->start( "cmd.exe", arguments ); But then cmd.exe complains not finding java...
I suspect there's some permission issue involved; I set my executable to be run as administrator, but no luck, so I have run out of ideas...
Obivously, java is installed in Windows 7 machine (calling it manually from cmd.exe works).