[Solved] Independant Threads with separate CommandLine
-
I meant the second snippet, using QProcess. Does that work?
-
According to the TaskManager a java.exe appears just for 1-2 seconds and disappears, but the jar is not executed properly.
-
And it does work from the command line itself? How about giving a complete path to your module.db - it's very likely that it is not found by your java application.
-
Yes, when I call "java -jar external.jar -m modules.db ... " it works.
I have catched in external.jar already if that modules.db file would not exist, it would throw an FileNotFound-Exception; but I'll try it.
-
Here I call another *.jar, Its a Server, which listens uninterrupted to a socket and prints status messages System.out.println("Bla") continously as well. This jar has an infinte while-loop and does not terminate..
SO when I start this, another cmd.exe opens and that output should be visible?@
void MyClass::runExternal()
{
QString t_exe_name("java.exe");
QStringList t_exe_arguments;
t_exe_arguments << "-jar" << "C:/SD_Projectz/TestServer/dist/TestServer.jar";QProcess *myProcess = new QProcess(p_ToObject);
QString t_joined = t_exe_arguments.join(" ");
QString t_all = QString("%1 %2").arg(t_exe_name).arg(t_joined);
myProcess->start(t_all);printf("\nWAIT: %d", myProcess->pid());
}
@Each start() my pid() is changed, visible on my Parent command line window, but no other cmd.exe opens for this Process.
When p_ToObject (the parent) is deleted, my process is terminated as well, right?
-
Why do you expect a cmd.exe running in case you start a java.exe?
-
These *.jars have System.out.println("kljdas"); so without any further cmd.exe nothing is visible?
Then the only way I recognize the running jar is the java.exe in the TaskManager?
And since the jar is running continuously, I would say my java.exe should not disappear?
-
Your java.exe does not "disappear". It has no user interface, so it runs in the background, where it belongs.
If you want to see the output of stdout or stderr, you should write a .bat file. Either this opens a cmd.exe automatically when run, or you have to give it as argument to cmd.exe.
-
Better yet: if you want to display the output, why not make your Qt application display it instead in some nicely integrated way? QProcess gives you access to the stdout and stderr outputs of the process, after all.
-
To start in a separate shell try to detach the Process. Then you have your own cmd.exe:
@myProcess->startDetached(prog_name, prog_arguments);@
But then you have no access to its stdio..hth!
-
[quote author="huckfinn" date="1317727677"]
But my external.jar continuously listens on the socket to a port, while the expected message is never being sent by my suspended Qt-Project.[/quote]If I get it right, you need to start the process in background, since it is a daemon, then startdetached should work for you. If you need to check only the output, you can redirect stdout to a log file (or embed a logging facility in your java application).
-
Yes, startDetached() works...
Thank you!