java -Dfile.encoding设置解决程序运行乱码问题
2013-07-31 10:49
579 查看
-Dfile.encoding解释:
在命令行中输入java,在给出的提示中会出现-D的说明:
-D<name>=<value>
set a system property
-D后面需要跟一个键值对,作用是通过命令行向java虚拟机传递一项系统属性
对-Dfile.encoding=UTF-8来说就是设置系统属性file.encoding为UTF-8
那么file.encoding什么意思?字面意思为文件编码。
搜索java源码,只能找到4个文件中包含file.encoding的文件,也就是说只有四个文件调用了file.encoding这个属性。
在java.nio.charset包中的Charset.java中。这段话的意思说的很明确了,简单说就是默认字符集是在java虚拟机启动时决定的,依赖于java虚拟机所在的操作系统的区域以及字符集。
代码中可以看到,默认字符集就是从file.encoding这个属性中获取的。
=====
Java's
file.encoding property on Windows platform
This property is used for the default encoding in Java, all readers and writers would
default to using this property. file.encoding is set to the default locale of Windows operationg system since Java 1.4.2. System.getProperty("file.encoding") can be used to access this property. Code such as System.setProperty("file.encoding", "UTF-8") can
be used to change this property. However, the default encoding can be not changed dynamically even this property can be changed. So the conclusion is that the default encoding can't change after JVM starts. java -dfile.encoding=UTF-8 can be used to set the
default encoding when starting a JVM. I have searched for this option Java official documentation. But I can't find it.
在命令行中输入java,在给出的提示中会出现-D的说明:
-D<name>=<value>
set a system property
-D后面需要跟一个键值对,作用是通过命令行向java虚拟机传递一项系统属性
对-Dfile.encoding=UTF-8来说就是设置系统属性file.encoding为UTF-8
那么file.encoding什么意思?字面意思为文件编码。
搜索java源码,只能找到4个文件中包含file.encoding的文件,也就是说只有四个文件调用了file.encoding这个属性。
在java.nio.charset包中的Charset.java中。这段话的意思说的很明确了,简单说就是默认字符集是在java虚拟机启动时决定的,依赖于java虚拟机所在的操作系统的区域以及字符集。
代码中可以看到,默认字符集就是从file.encoding这个属性中获取的。
=====
Java's
file.encoding property on Windows platform
This property is used for the default encoding in Java, all readers and writers would
default to using this property. file.encoding is set to the default locale of Windows operationg system since Java 1.4.2. System.getProperty("file.encoding") can be used to access this property. Code such as System.setProperty("file.encoding", "UTF-8") can
be used to change this property. However, the default encoding can be not changed dynamically even this property can be changed. So the conclusion is that the default encoding can't change after JVM starts. java -dfile.encoding=UTF-8 can be used to set the
default encoding when starting a JVM. I have searched for this option Java official documentation. But I can't find it.
相关文章推荐
- java -Dfile.encoding设置解决程序运行乱码问题
- 写了一个查询数据库的程序,不熟的Tomcat6。查询条件为英文时运行正常,为中文时出现乱码。后在tomcap的server.xml中加入useBodyEncodingForURI="true解决了问题
- 解决httpclient在eclipse运行编码正常,ant编译打包后运行获取数据为乱码的问题(-Dfile.encoding)
- java、javac -version不一致(java编译及运行环境不一致)的环境变量设置问题解决
- Codeblock解决注释乱码问题及在ubuntu中程序运行时乱码问题。
- Sublime Text3 解决编辑java保存后在cmd下运行中文显示乱码的问题
- java程序向mysql数据库插入数据中文 乱码问题解决
- Java -Dfile.encoding=UTF-8 出现乱码问题原因分析
- 根据不同的操作系统(64/32),设置文件以64位运行。又可解决问题:“试图加载不正确的程序”。
- 解决无法在java程序中运行cmd命令的问题
- 解决Linux服务启动Java程序日志文件出现中文乱码的问题
- Java程序中遇到的乱码问题以及解决方法
- 在eclipse中JAVA从打包成jar程序到双击运行的整个过程(没有主清单属性问题的解决)
- Java程序中遇到的乱码问题以及解决方法
- 谈谈怎么解决Java程序和数据库交互出现乱码的问题
- 对Java程序中的中文乱码问题的解决方法
- 解决打开Android SDK Manager时出现“.....\sdk\tools\lib\\find_java.exe不是内部或外部命令,也不是可运行的程序或批处理文件“问题
- 解决 Java 程序的乱码问题
- java程序解决中文乱码问题
- 在 Sublime Text 2 中编译和运行 Java 程序,以及输出中文出错问题解决办法