gpt4 book ai didi

java - 通过IDE(intelliJ)运行Shell脚本并接收: Windows Subsystem for Linux has no installed distributions

转载 作者:行者123 更新时间:2023-11-30 05:33:59 26 4
gpt4 key购买 nike

通过 IDE (inteliJ) 运行 Shell 脚本并接收:Linux 的 Windows 子系统没有安装发行版,有什么想法吗?

我的代码:

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 脚本,需要安装适用于 Linux 的 Windows 子系统。您可能想尝试安装它。或者,如果您将 bash 脚本转换为 Windows 批处理脚本,则可以通过启动 cmd 来运行它。

关于java - 通过IDE(intelliJ)运行Shell脚本并接收: Windows Subsystem for Linux has no installed distributions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56993524/

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