Discussion:
[exec] Starting an independent process
(too old to reply)
Stefan Reich
2018-07-01 12:36:09 UTC
Permalink
Hi,

I want to start independent processes from Java, either other Java VMs or
something like a browser.

On Linux, from within Java I start a shell script containing "nohup ... &"
which works fine.

On Windows, I use a .bat script, but I'm having problems with that.
Sometimes it works, sometimes it doesn't.

It seems to me that starting another Java VM is a standard task that many
developers will face.

How can it be solved using Exec?

Many greetings,
Stefan Reich / BotCompany.de
Stefan Reich
2018-07-01 13:09:57 UTC
Permalink
Hi Martin!

The Commons Exec version I use is 1.3.

On Windows, I actually use Runtime.exec currently:

String[] command = {"cmd", "/c", "start", "/b", scriptFile.getPath() };
Process process = Runtime.getRuntime().exec(command);

where scriptFile is a .bat containing the actual command I want to run
("java ...").

Unrelated to my setup, I am wondering if there is a canonical way to
do these things. It seems such a standard task.

If Commons Exec had an "independent process" flag, that would be perfect!


Many greetings,

Stefan
please post the version of commons-exec you're using (you can show us the
pom.xml)
please post contents of bat file you are executing
*gruss*
______________________________________________
------------------------------
*Sent:* Sunday, July 1, 2018 8:36 AM
*Subject:* [exec] Starting an independent process
Hi,
I want to start independent processes from Java, either other Java VMs or
something like a browser.
On Linux, from within Java I start a shell script containing "nohup ... &"
which works fine.
On Windows, I use a .bat script, but I'm having problems with that.
Sometimes it works, sometimes it doesn't.
It seems to me that starting another Java VM is a standard task that many
developers will face.
How can it be solved using Exec?
Many greetings,
Stefan Reich / BotCompany.de
--
Stefan Reich
BotCompany.de // Java-based operating systems
Loading...