Paul - The Programmer

simple & stupid

Hide Vim menu bar and tool bar

" Hide the menu bar

:set guioptions-=m

" Hide the tool bar

:set guioptions-=T

Configure javac to report messages in English

On my Chinese version Windows XP, the javac always shows Simple Chinese messages. But I'd rather see the English ones.

The traditional way is to change the default system Local setting, then the JVM local is changed as well. But this solution is too inconvenient and painful.

Fortunately, we do not have to do that. We can pass the '-J-Duser.language' option to the javac to change its JVM Local setting.


javac '-J-Duser.language=en' -help

 The javac will show the help messages in English instead of the Simple Chinese.

Those two options can also be passed in the ant script by adding the <compilerarg> in the <javac>


<target name="compile" description="compile hello world">
       <mkdir dir="${classes}"/>
       <javac srcdir="${src}" destdir="${classes}"  fork="true" >
           <compilerarg value="-J-Duser.language=en"/>
           <compilerarg value=""/>

The attribute fork="true" is mandatory. The two options can only effect the forked compiler.

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.




find & insert new line with VIM

:%s/$/\rthis is a new line/g

\r is the new line character in VIM.

Have Perl modules all in one file

This is so good for me when I practise the OO concept in Perl. Do not need to switch among the module files anymore. :)

package Foo;  # start the class package

sub new {
    print "In Foo::new\n";
    my $self = bless {}, 'Foo';
    return $self;

package main;   # get back to the main package

my $bar = Foo->new; # this is the first line for interpreter to read
print "$bar\n";