[exec] Starting an independent process

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[exec] Starting an independent process

Stefan Reich
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
Reply | Threaded
Open this post in threaded view
|

Re: [exec] Starting an independent process

Stefan Reich
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


On 1 July 2018 at 14:39, Martin Gainty <[hidden email]> wrote:

> 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*
> ______________________________________________
>
>
> ------------------------------
> *From:* Stefan Reich <[hidden email]>
> *Sent:* Sunday, July 1, 2018 8:36 AM
> *To:* [hidden email]
> *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