This article describes how to configure charset for a JVM.
We faced an issue on a Linux environment, a file containing some Swedish character was not being read correctly by underlying JVM since the default charset of JVM was picked as
UTF-8 (which does not support some Swedish character). But on the other hand, in Windows environment, it was working fine since the default charset was picked as
Windows-1252 (which does support these characters).
Here are the steps to solve the issue
ISO-8859-1 is the standard character encodings, generally intended for Western European languages. This charset can be set for JVM in Linux and Windows environments for Western European languages.
So, to tell JVM which charset should it pick, irrespective of the environment, can be defined from command line in JVM.
Example for Tomcat server, make the following changes
- Open catalina.sh in your TOMCAT/bin directory and set the
JAVA_OPTS to change default charset to
ISO-8859-1 using below statement
JAVAOPTS="$JAVAOPTS -Dfile.encoding=ISO-8859-1" and then restart the server.