Java 通过IDE(inteliJ)运行Shell脚本并接收:Windows Subsystem for Linux没有安装发行版
通过IDE(inteliJ)运行Shell脚本并接收:Windows Subsystem for Linux没有安装发行版,你知道为什么吗 我的代码:Java 通过IDE(inteliJ)运行Shell脚本并接收:Windows Subsystem for Linux没有安装发行版,java,windows,shell,sh,Java,Windows,Shell,Sh,通过IDE(inteliJ)运行Shell脚本并接收:Windows Subsystem for Linux没有安装发行版,你知道为什么吗 我的代码: public class TestScript { public static void main(String args[]) throws IOException, InterruptedException { String[] cmd = { "bash", "-c", "ExecutorTest.sh" };
public class TestScript {
public static void main(String args[]) throws IOException, InterruptedException {
String[] cmd = { "bash", "-c", "ExecutorTest.sh" };
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
p.waitFor();
}
}
输出:
Windows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
为了能够在Windows机箱上运行bash和bash脚本,需要安装Windows Linux子系统。您可能想尝试安装它。或者,如果将bash脚本转换为Windows批处理脚本,则可以通过启动
cmd
来运行它。是否已安装Windows Susbsystem for Linux?