How to set the JVM charset on the command line?

十年热恋 提交于 2019-12-22 12:38:38

问题


What's the command to set the JVM's character set?

(Also, what's the command to view the current JVM's character set, so I know how to reset it back to default after I'm done)

Thanks,


回答1:


java strings are always utf-16 internally (javadoc link), but you can use -Dfile.encoding=UTF-8 to facilitate reading files with a default charset.

Just ensure java has access to that fileset when you set it or it won't start.




回答2:


java.nio.charset.Charset.defaultCharset() Will get you the JVM's default charset.



来源:https://stackoverflow.com/questions/10890578/how-to-set-the-jvm-charset-on-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!