Eclipse is an open source community, whose projects are focused on building an open development platform comprised of extensible frameworks, tools and runtimes for building, deploying and managing software across the lifecycle.
Eclipse Console Output in Unicode
Eclipse BUG: #13865. You will not get Unicode output in Eclipse Console while using System.out directly in Windows.
The following are the steps to get Eclipse’s console to display text in UTF-8.
- Add -Dfile.encoding=UTF-8 to your eclipse.ini
-
Go to Eclipse -> Preferences -> General -> Appearance -> Colors and Fonts -> Debug -> Console font
Choose a Unicode font, like Lucinda Sans Unicode -
If you are using Windows or do not want to change your OS encoding, you will
have to avoid using System.out stream directly. Instead, wrap it up with
java.io.PrintStream:
PrintStream out = new PrintStream(System.out, true, "UTF-8");
out.println("\u2297\u0035\u039e\u322F\u5193");
-
If you are using Log4J with
ConsoleAppender, make sure to set the encoding property to UTF-8. Example:
#TRACE appender
log4j.appender.stdout.trace=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.trace.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.trace.encoding=UTF-8
log4j.appender.stdout.trace.layout.ConversionPattern=%p [%c] - %m%n
log4j.appender.stdout.trace.Threshold=TRACE