Change Tomcat's Charset.defaultCharset in windows

nonouco picture nonouco · Jul 5, 2012 · Viewed 41k times · Source

I'm using tomcat 6.0.32 in windows 7. Inside a very simple servlet, inside the init method, I'm printing:

System.out.println(Charset.defaultCharset());

The output is:

windows-1253

As far as I understand this is how tomcat start's in the JVM since I'm printing the same in standalone java class and I get "UTF8" as a response.

So, how can I change this to UTF-8?

thanks

Answer

nonouco picture nonouco · Jul 5, 2012

Just create a setenv.bat file inside the TOMCAT/bin directory with the following contents:

set "JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF8"