Wender
Wender

Reputation: 1001

Use Ant to launch Java program with cmd.exe "start" command

<exec dir="${basedir}" executable="cmd.exe">
   <arg line="start cmd /c java -jar ${jar.file} "/>
</exec>

In Eclipse this does not work, I would like to open my app. The reason is io.Console because this I can't execute the app in Eclipse.

Upvotes: 0

Views: 71

Answers (1)

Chad Nouis
Chad Nouis

Reputation: 7041

cmd appears in two places: In the executable attribute and in the <arg>. It should only appear in the executable attribute.

Further, the /c option of cmd.exe should appear before the start command, not after.

Try the following:

<exec executable="cmd.exe" failonerror="true">
    <arg value="/c"/>
    <arg value="start"/>
    <arg value="java"/>
    <arg value="-jar"/>
    <arg value="${jar.file}"/>
</exec>

Upvotes: 1

Related Questions