I am writing a Windows application using Qt (4.6.1), which uses the 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";
arguments << "-blah-blah";
process->start( "java", arguments );
This is how I run the Java application and it works fine, but as far as I tested only on my Windows XP machine. When I tested this on another Windows 7 computer, it failed.
In Windows 7, after a process-> start (...), a QProcess (QProcess :: ProcessError) error occurs , which gives me a QProcess :: FailedToStart error
: QStringList; < "/"; < ""; < "-jar"; < "Absolute_path\app.jar";// Java, < "-blah-";// Java- process- > start ( "cmd.exe", );
cmd.exe , java...
, ; , , ...
, java Windows 7 ( cmd.exe).