一个简单的方法是, 配置环境变量添加一个 option 到 JAVA_TOOL_OPTIONS

比如如下:

export JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"

在windows 下, 可以在环境变量里面添加个key为 JAVA_TOOL_OPTIONS, value 为 "-Dfile.encoding=UTF8"

在 *nix,可以写配置文件比如

export JAVA_TOOL_OPTIONS=$JAVA_TOOL_OPTIONS" -Dfile.encoding=UTF8 "
sbt compile run

也可以启动时候写成

env JAVA_TOOL_OPTIONS=$JAVA_TOOL_OPTIONS" -Dfile.encoding=UTF8 " sbt compile run

两者区别是, 前者会在当前 session 下一直保持这个 JAVA_TOOL_OPTIONS 环境变量. 你可以把 "export xxx" 一行直接写在 ~/.bash_profile, ~/.bashrc 等配置文件, 每次启动先执行它

而后者仅仅在当前命令使用该环境变量

Categories: Code

Yu

Ideals are like the stars: we never reach them, but like the mariners of the sea, we chart our course by them.

Leave a Reply

Your email address will not be published. Required fields are marked *