3

In my java program I want to output this character: ⊨

It works in Eclipse but doesn't on my bash console.

Here's my main:

public static void main(String[] args) {
    System.out.println(System.getProperty("file.encoding"));
    System.out.println(Charset.defaultCharset().name());
    String original = "\u22A8";
    System.out.println("original = " + original);
}

Here's my output in Eclipse built-in console. Note that I set Run Configurations > Common > Encoding > Other > UTF-8

UTF-8
UTF-8
original = ⊨

Here's my output on terminal when invoking with java -Dfile.encoding=UTF-8 Main

UTF-8
UTF-8
original = â¨

Here's my output on terminal when invoking with java Main

ANSI_X3.4-1968
US-ASCII
original = ?

How can I make it work on console?

hooch
  • 1,135
  • 1
  • 16
  • 31

1 Answers1

1

I forgot to set the encoding inside the console. So when setting it to UTF-8, the invocation java -Dfile.encoding=UTF-8 Main yields the correct result.

hooch
  • 1,135
  • 1
  • 16
  • 31
  • How exactly do you set the encoding inside the console? Window / Preferences / Run-Debug / Console does not have such option – quiet-ranger Apr 03 '22 at 19:16