QProcess does not start Java application under windows 7

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";   //the java app that I want to execute
arguments << "-blah-blah";              //some java app arguments
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).

+3
1

, QProcess, . , /QProcess , - , , , .

, QProcess , , , :

qDebug() << QProcess::environment();

, .

+1

Source: https://habr.com/ru/post/1735557/


All Articles