简体   繁体   English

System.out.println不在Windows Linux子系统bash中打印

[英]System.out.println doesn't print in Windows Linux Subsystem bash

I have a very simple Hello World java program that just prints a line using System.out.println : 我有一个非常简单的Hello World java程序, System.out.println使用System.out.println打印一行:

package test;

public class Main {

    public static void main(String[] args) {
        System.out.println("Start");
    }
}

When I execute this code in a Windows terminal or a native Linux terminal it works fine, when I try to execute it in the Ubuntu bash of the Windows Subsystem for Linux (WSL) it's not showing anything. 当我在Windows终端或本机Linux终端中执行此代码时,它工作正常,当我尝试在Windows子系统Linux(WSL)的Ubuntu bash中执行它时,它没有显示任何内容。 If instead I use System.err.println it prints the line. 相反,我使用System.err.println打印该行。 I didn't have similar problems with Python. 我没有Python的类似问题。

My java version is: 我的java版本是:

java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

This should work fine. 这应该工作正常。 First, I'd suggest ensuring you're running Windows 10 Fall Creators Update (or later). 首先,我建议您确保运行Windows 10 Fall Creators Update(或更高版本)。 Then make sure you've applied all the latest updates to your distro (assuming Ubuntu: sudo apt update && sudo apt upgrade 然后确保你已经将所有最新的更新应用到你的发行版(假设Ubuntu: sudo apt update && sudo apt upgrade

Then you should be able to do this: 然后你应该能够做到这一点:

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM