You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Stefan Reich <st...@googlemail.com.INVALID> on 2018/07/01 12:36:09 UTC

[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

Re: [exec] Starting an independent process

Posted by Stefan Reich <st...@googlemail.com.INVALID>.
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 <mg...@hotmail.com> 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 <st...@googlemail.com.INVALID>
> *Sent:* Sunday, July 1, 2018 8:36 AM
> *To:* user@commons.apache.org
> *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