Nilotpal Nilotpal - 3 years ago 277
Java Question

What does -Dfile.encoding = UTF-8 do in JAVA_OPTIONS

Any idea what does -Dfile.encoding=UTF-8 in

JAVA_OPTIONS="${JAVA_OPTIONS} -Dfile.encoding=UTF-8"

I have this option in my jetty server configuration.

If i dont have it, what might be consequence?

Answer Source

It sets a property which defines in which encoding will Java save and read files by default. It must be set at JVM startup.

There are multiple encodings - ways to represent characters on computers. UTF-8 is one of the best to use, as it contains all special characters in many languages.

Once you don't have this property, Java might save files in a different encoding which might lead to strange characters when opening the file with text editor. You can avoid this issue by manually setting the desired encoding to your OutputStreams.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download