'How to let the feedback text from Java compiler to be UTF-8

How to let the feedback text from Java compiler to be UTF-8

I mean, for example, my HelloWorld.java has an compile error:

public class HelloWorld{
  public static void main(String[] args){
​    System.out.println("Hello World") //missing ; deliberately
  }
}

Then I run "javac HelloWorld.java"

The compiler shows:

enter image description here

.\HelloWorld.java:3: ����: ��Ҫ';'
        System.out.println("Hello World")
                                         ^
1 ������

My computer is Windows 11 with Chinese Language, and JDKs are corretto11, openjdk15, openjdk16 (they behave the same).

I've searched Stackoverflow for "javac" "encoding", but what the questions were saying is how to

"System.out.println("Chinese 中文)", but not my question.

Usually, I am using IntelliJ IDEA to learn and write Java, and it seems it has some method to let javac to output in a correct encoding, but I cannot find it.

Any help to this question would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source