简体   繁体   English

使用Ant通过cmd.exe“启动”命令启动Java程序

[英]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. 在Eclipse中这不起作用,我想打开我的应用程序。 The reason is io.Console because this I can't execute the app in Eclipse. 原因是io.Console,因为这无法在Eclipse中执行该应用程序。

cmd appears in two places: In the executable attribute and in the <arg> . cmd出现在两个位置: executable属性和<arg> It should only appear in the executable attribute. 它仅应出现在executable属性中。

Further, the /c option of cmd.exe should appear before the start command, not after. 此外, cmd.exe/c选项应该出现在start命令之前,而不是之后。

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM