javaemojiwindows-terminal

How to print an emoji using Java in Windows Terminal?


There are 3 essential elements to the question:

Trying it directly shows a question mark:

enter image description here

Trying to set an environment variable doesn't help:

enter image description here

I've also tried chcp 65001, setting the encoding to utf-8 in Java code, etc., none of these methods worked. I tried echo "🥲" and it worked just fine, but I want to use this in Java.

I've done a huge amount of literature research with no useful results. Everyone claims they have solved the problem using a method that doesn't work for me.


Solution

  • You can try this:

    System.console().writer().write("🥲")