从Java打开一个新的提示/终端窗口 [英] Open a new prompt/terminal window from Java
本文介绍了从Java打开一个新的提示/终端窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想打开一个新的终端窗口,它会在打开时运行某个命令。它最好需要是一个真正的原生窗口,我不介意为linux / osx / windows编写不同的代码。
I want to open a new terminal window, which will run a certain command upon opening. It preferably needs to be a real native window, and I don't mind writing different code for linux/osx/windows.
我假设模拟终端可以工作,只要它支持真正的终端所做的一切,而不仅仅是打印命令的输出行。
I'm assuming an emulated terminal would work, as long as it supports everything a real terminal would do and isn't just printing lines of output from a command.
推荐答案
打开一个实际的终端窗口肯定需要为每个OS提供不同的代码。对于Mac,你需要类似的东西:
Opening an actual terminal window will definitely require different code for each OS. For Mac, you want something like:
Runtime.getRuntime().exec("/usr/bin/open -a Terminal /path/to/the/executable");
这篇关于从Java打开一个新的提示/终端窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文