tags:

views:

2194

answers:

3

Whether the default encoding for jvm is UTF-8 or some other? In jvm where it will be mentioned?

+2  A: 

It's going to be locale-dependent. Different locale, different default encoding.

skaffman
+17  A: 

The default character set of the JVM is that of the system it's running on. There's no specific value for this and you shouldn't generally depend on the default encoding being any particular value.

It can be accessed at runtime via Charset.defaultCharset(), if that's any use to you, though really you should make a point of always specifying encoding explicitly when you can do so.

Andrzej Doyle
+3  A: 

Note that you can change the default encoding of the JVM using the confusingly-named property file.encoding.

If your application is particularly sensitive to encodings (perhaps through usage of APIs implying default encodings), then you should explicitly set this on JVM startup to a consistent (known) value.

Brian Agnew
Note that `file.encoding` must be specified on JVM startup (i.e. as cmdline parameter -Dfile.encoding or via JAVA_TOOLS_OPTIONS); you can set it at runtime, but it will not matter. See http://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding
sleske