【问题标题】:Running Shell Script via IDE (inteliJ) and receiving: Windows Subsystem for Linux has no installed distributions通过 IDE (intelliJ) 运行 Shell 脚本并接收:Windows Subsystem for Linux has no installed distributions
【发布时间】:2019-11-21 10:16:20
【问题描述】:

通过 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

【问题讨论】:

  • 您是否安装了适用于 Linux 的 Windows 子系统?

标签: java windows shell sh


【解决方案1】:

为了能够在 Windows 机器上运行 bash 和 bash 脚本,需要安装适用于 Linux 的 Windows 子系统。您可能想尝试安装它。或者,如果将 bash 脚本转换为 Windows 批处理脚本,则可以通过启动 cmd 来运行它。

【讨论】:

    猜你喜欢
    • 2018-10-21
    • 2016-12-13
    • 2013-03-22
    • 1970-01-01
    • 2021-03-20
    • 2017-09-24
    • 1970-01-01
    • 2011-07-27
    • 2016-03-08
    相关资源
    最近更新 更多