Paul - The Programmer

simple & stupid

Fix the Jython console on my Windows XP

The Jython console didn't work properly on my Chinese version Windows XP. It can not interprete the strings properly.


>>> print "hello world"


Looks like it's looking for a futher input.  After I input a '\n', ther console crashed and complains

LookupError: unknown encoding 'gb18030'.

This error never happens on the English version Windows XP. So, this problem definitely caused by the system default encoding.


With a few hours study for the JVM & the Jython encoding setting, I found 2 solutions.

1)  Change the JVM default character encoding

Start up the jython with option -Dfile.encoding=UTF8,then the Jython console's encoding will be UTF8 as well.


jython -Dfile.encoding=UTF8

For change the JVM encoding automatically, you can also create one environment variable JAVA_TOOL_OPTIONS to -Dfile.encoding=UTF8.


set JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"

2) Change the Jython console character encoding

Start up the jython with option -Dpython.console.encoding=UTF8


jython -Dpython.console.encoding=UTF8

Or add this setting in the Jython registry file. On my laptop, the file is C:\jython25\registry


Now, you enjoy.