Scala, Mac and -Dfile.encoding=UTF-8
Today, I noticed that my Scala can't print any Japanese characters on my MacBook.
% sbt [info] Set current project to default-7cb4b4 (in build file:/Users/kzys/hello/) > console [info] Starting scala interpreter... [info] Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29). Type in expressions to have them evaluated. Type :help for more information. scala> println("\u3041") �� scala>
Actually, It caused from Java, not Scala, not sbt.
You must pass -Dfile.encoding=UTF-8
to java(1). But how?
I find a good answer on Stack Overflow.
Since the command-line cannot always be accessed or modified, for example in embedded VMs or simply VMs launched deep within scripts, a JAVA_TOOL_OPTIONS variable is provided so that agents may be launched in these cases.
% JAVA_TOOL_OPTIONS='-Dfile.encoding=UTF8' sbt Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8 [info] Set current project to default-7cb4b4 (in build file:/Users/kzys/hello/) > console [info] Starting scala interpreter... [info] Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29). Type in expressions to have them evaluated. Type :help for more information. scala> println("\u3041") ぁ scala>
Ok, I will add JAVA_TOOL_OPTIONS
on my .zshrc.