在Java中通过进程启动应用程序而不关闭父应用程序?
我正试图通过Java启动League Of Legends应用程序,它可以正常工作,但为了让它跳过League Of Legends加载徽标,我需要关闭父应用程序 下面是运行它的代码:在Java中通过进程启动应用程序而不关闭父应用程序?,java,process,runtime,Java,Process,Runtime,我正试图通过Java启动League Of Legends应用程序,它可以正常工作,但为了让它跳过League Of Legends加载徽标,我需要关闭父应用程序 下面是运行它的代码: File dir = new File("C:/Riot Games/League of Legends/RADS/solutions/lol_game_client_sln/releases/0.0.1.110/deploy/"); String[] cmd = new
File dir = new File("C:/Riot Games/League of Legends/RADS/solutions/lol_game_client_sln/releases/0.0.1.110/deploy/");
String[] cmd = new String[] {
dir.getAbsolutePath() + File.separator + "League of Legends.exe",
"8394",
"LoLLauncher.exe",
"\"\"",
"spectator spectator.na.lol.riotgames.com:80 " + currentGame.getObservers().getEncryptionKey() + " " + currentGame.getGameId() + " NA1"};
try {
Runtime.getRuntime().exec(cmd, null, dir);
} catch (IOException e) {
e.printStackTrace();
}
它只是说,如果父应用程序仍处于打开状态,则不响应。在我关闭父应用程序后,它立即开始加载并工作。可能是LOL从其stdio流中转储了大量数据,而您没有从流程对象中获取这些数据。您可能需要启动一个线程,该线程只需坐下来吞下Process.getInputStream()或Process.getErrorStream中显示的内容即可。我使用了我找到的StreamGobbler,并将输入和错误流输入其中,它就像魔术一样工作!谢谢你的帮助