gpt4 book ai didi

java - 使用命令行参数启动 .jar 文件(但没有控制台窗口)

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:04:38 25 4
gpt4 key购买 nike

我要做一个应用程序的演示,该应用程序有一个 server.jar 和 client.jar。两者都有命令行参数并且是可执行的。我需要启动两个 server.jar 实例和两个 client.jar 实例。

我认为使用批处理文件是可行的方法,但是,批处理文件执行第一个命令(即 >server.bat [argument1] [argument2])并且不执行任何其他操作,除非我关闭第一个实例,在这种情况下,它会运行第二条命令。还有我不想打开(或最小化)一个空白的控制台窗口

我真正需要的是一个批处理脚本,它可以在没有任何控制台窗口的情况下启动这些应用程序并启动我需要的所有实例。

提前致谢!

编辑:

java :

works if I type the command into the console window individually. If I put the same in the batch file, it will behave as before. Console window opens, one instance starts (whichever was first) and it does not proceed further unless I close the application in which case it runs the 2nd command. I want it to run all commands silently

最佳答案

找到解决方案,下面是我的批处理文件的内容

@echo off

start /B server.jar [arg1] [arg2]
start /B server.jar [arg3] [arg4]

start /B client.jar [arg5]
start /B client.jar [arg6]

@echo on

这将打开、运行所有命令并关闭窗口,不等待命令完成。

我仍然不确定如何防止窗口完全打开。

关于java - 使用命令行参数启动 .jar 文件(但没有控制台窗口),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/711370/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com