Java获取Linux服务器系统默认编码格式
一:查找java进程
ps -ef | grep java
二:使用jinfo命令查看java系统参数
jinfo -sysprops 进程id
Usage:
jinfo [option] <pid>
(to connect to running process)
jinfo [option] <executable <core>
(to connect to a core file)
jinfo [option] [server_id@]<remote server IP or hostname>
(to connect to remote debug server)
where <option> is one of:
-flag <name> to print the value of the named VM flag
-flag [+|-]<name> to enable or disable the named VM flag
-flag <name>=<value> to set the named VM flag to the given value
-flags to print VM flags
-sysprops to print Java system properties
<no option> to print both of the above
-h | -help to print this help message
最后三行
java.vm.name = Java HotSpot(TM) Client VM
file.encoding = UTF-8
java.specification.version = 1.8
也可以使用locale命令查看
[www@iZwz9ikd8ja49b7v8dhqihZ ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
如果想修改系统编码:
修改/etc/sysconfig/i18n,如改成中文编码:
LANG=en_US.UTF-8
改为
LANG="zh_CN.GBK"
然后在不重启的情况下重新加载i18n文件
root@ubuntu:/etc# source /etc/sysconfig/i18n
参考https://www.cnblogs.com/xxiong1031/articles/6884457.html