Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过IDE(inteliJ)运行Shell脚本并接收:Windows Subsystem for Linux没有安装发行版_Java_Windows_Shell_Sh - Fatal编程技术网

Java 通过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" };

通过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" };
        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?