Author Archives: Zhou Renjian

Vista Media Player Cannot Play mms:// Stream

OK. Windows Media Player 11.0 (WMP 11) does not support mms:// protocol any more. So your Vista will never play mms:// stream. Stop wasting your time on searching for a solution.

If you are using XP, you may reinstall Windows Media Player 10.0. But you won’t have chance to downgrade Vista’s WMP 11 to WMP 10.

If the mms:// stream seems to be working for your Vista, it’s not. In fact, the stream media server supports rstp:// protocol stream, and WMP try to rollover mms:// to rtsp:// or http://.

That is my conclusion after reading tons of web pages about Vista’s Media Player on mms. If my conclusion is wrong, please correct me.

Posted in Uncategorized | Tagged , , , | 2 Comments

True Color Remote Desktop Connection

If you use Windows’ Remote Desktop Connection a lot, you will find that the UI is a little ugly. In fact by default, the Remote Desktop Connection is in 16 bit color mode. In order to have a better experience, it would better setup a true color remote desktop connection. Here are instructions for you.

For Windows Vista users, you already have the latest remote desktop clients, so you can make sure that your connection’s “Options” is using “High Quality (32 bit)” color in “Display” tab, and using “LAN (10Mbps or higher)” in “Experience” tab.

If you are using Windows Vista Professional or Windows Vista Premium, you may following similar instructions of “Enhance Terminal Services’ Color Depth by MMC” to make your connection become true color (24 bit) connection. If you are using Windows Vista Home Edition, you can use registry editor to add a key as following:

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Terminal Services]

Or you can download the registry file VistaTerminal24bitColor.reg and merge it into your system.

If you are using Windows XP or 2003, you need to upgrade your Terminal Services Client to 6.0. And then following the above MMC enhancement instructions or add a new key in registry:

[HKEY_CURRENT_USER\Software\Policies\Microsoft\WindowsNT\Terminal Services]

Or you can download the registry file XPTerminal24bitColor.reg and merge it into your system.


Posted in Uncategorized | Tagged | Comments Off on True Color Remote Desktop Connection

Implementing Web AIM Client

Here are some notes when I was struggling to develop a web AIM client:

1. Download AIM SDK, both Windows and Linux
In Linux environment, you may already have NSS/NSPR libraries installed, if not following instructions to install it. You only need to run:

cd dist/release/
ln -s /usr/lib/ .
ln -s /usr/lib/ .
ln -s /usr/lib/ .
ln -s /usr/lib/ .
ln -s /usr/lib/ .
ln -s /usr/lib/ .
ln -s /usr/lib/ .
ln -s /usr/lib/ .
ln -s /usr/lib/ .
export LD_LIBRARY_PATH=/usr/local/tomcat/lib/

2. Get a developer key to use AIM SDK. The developer web site does not accept external email account, so create a new one. In fact, more new AIM screen names are needed, as testing AIM requires it.

3. Try to compile and run samples/accjsample:

cd samples/accjsample
javac -cp ../../dist/release/accjwrap.jar
java -cp ../../dist/release/accjwrap.jar:./ AccJSample username password developerkey

But you may get error messasge like:

at Method)
at AccJSample.(
at AccJSample.main(

But if you go into dist/release/ directory, where *.so are located, and run:

/usr/local/java/bin/java -cp ../../dist/release/accjwrap.jar:../../samples/accjsample/ AccJSample username password developerkey

You may get things running correctly:

[5/5/08 8:34 AM]: OnStateChange: Connecting, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Validating, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Transferring, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Negotiating, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Starting, ACC_S_OK
[5/5/08 8:34 AM]: OnStateChange: Online, ACC_S_OK
[5/5/08 8:34 AM]: OnUserChange: ACC_S_OK

That is because *.so may not be loaded correctly if they are not in the current working directory.

Someone says that inaccurate time may cause problems, so run:

/etc/init.d/ntpd start

to synchronize your server’s time.

4. following, it comes to the time that developing AIM desktop client, and then converting it into Java Servlet based AIM client. So, tutorial “Creating AIM-Enabled Application in Java” series are recommended.

5. And time to deploy your web AIM client to tomcat servlet container.

If your Tomcat 6 server is on Windows, you may need to copy all dist/release/*.dll into your %CATALINA_HOME%/bin/ folder, copy dist/release/accjwrap.jar into %CATALINA_HOME%/lib and restart Tomcat services to get things done. Deploy accjwrap.jar directly into webapps folder is not recommended, because you may want to restart your servlet application frequently while loading and unloading *.dll modules may cause “already loaded in another classloader UnsatisfiedLinkError” problems for Tomcat, which may result that you need to restart your Tomcat server.

If your Tomcat 6 server is on Linux, you also need to copy all dist/release/*.so into your $CATALINA_HOME/bin/ folder, copy dist/release/accjwrap.jar into $CATALINA_HOME/lib. And you need to modify your and add two lines:


And then restart Tomcat server.

Related links:

Posted in Java, Tomcat | Tagged | 10 Comments


I learned to use JavaCC these days. And I found that JavaCC is a great toolkit.

What is JavaCC?

JavaCC is short for Java Compiler Compiler. It is a parser or scanner generator for Java.

Java Compiler Compiler [tm] (JavaCC [tm]) is the most popular parser generator for use with Java [tm] applications. A parser generator is a tool that reads a grammar specification and converts it to a Java program that can recognize matches to the grammar. In addition to the parser generator itself, JavaCC provides other standard capabilities related to parser generation such as tree building (via a tool called JJTree included with JavaCC), actions, debugging, etc.

You can find a lot of language grammar and AST on its site too. I see that C++ and Java 1.5 grammar are there. JavaScript isn’t there. But I find out that Dojo toolkit’s JSLinker provides an ECMAScript 262 one. That is to say, you can create parser and parse C++, Java or JavaScript sources into your AST for any uses. Lots of great features can be imagined.

I spent about a week learning and using JavaCC. I completed a parser for an IDL language named CAR. I also built an Eclipse editor using the generated AST parser. Bang, all things seems working well: keyword hight-lighting, outline view, error probing, … Great toolkit!

Using JavaCC is quite simple, just download and unzip it, then following its examples tutorial. I sugguest you to start with JavaGrammars and VTransformer examples, as they are about Java grammar.

I think, later, given opportunity, I will try JavaCC out on other projects. Maybe my Java2Script compiler would be benefited from JavaCC.

P.S. Update:
There is a JavaCC Eclipse Plugin project, you can download the plugin to help you writing your syntax file.

Posted in C++, Java, JavaScript | Tagged , | 2 Comments

Moving Server Lesson

1. Moving server from IP to another IP may have a lot of problems. DNS may not be totally updated to all of visitor. So keep the old server running as possible.
2. Old content should not be removed immediately. Some visitors may visit your page directly and get cached *.html, which will try to visit old resources. Lots of 404 responses will occur.
3. Every page should be tested. Or bugs will fly all over.
4. All operations should be record so the next time, you can follow last time’s steps to save time.

Posted in Uncategorized | Comments Off on Moving Server Lesson

Java Puzzlers

They are really very puzzling. Please check them out:
Advanced Topics in Programming Languages: Java Puzzlers, Episode VI

Posted in Java | 2 Comments

Eclipse Freezing on Start

After an incorrect shutdown, Eclipse can not start, freezing on splash window.

I opened file
there was a line saying:

The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes

After taking many tries, I found a solution for this bug. Just remove folder
and restart Eclipse. Everything will be fine again.

Posted in Bug Fix, Eclipse | 16 Comments

Port Mapping on Linux

Mapping port 80 to inner port 8080:
/sbin/iptables -t nat -A PREROUTING -i eth+ -p tcp –dport 80 -j REDIRECT –to-port 8080

Well, I use this trick to avoid firewall blocking.

For binding more HTTP servers on different server implementations:

/sbin/iptables -t nat -A PREROUTING -i eth+ -p tcp -d –dport 80 -j REDIRECT –to-port 8080
8080 is another server implementation’s listening port

Posted in Tricks | 3 Comments

Maximum Connections for Tomcat, Apache and Comet

I struggled to find out why my server broke down frequently these days. And I think I found it.

My Apache HTTP server was configured with MaxClients at 50, the default AJP connector’s connections number was about 15, and the Tomcat’s maxThreads was 150. So the bottleneck would be AJP connector, especially all my connection-heavy Comet application was serving about 20 Gtalk/MSNLive simultaneous connections. It is obviously it will break down the servers. And after switching my Gtalk/MSNLive into query modes, it still broke down the server. The reason may be the bottleneck of Apache HTTP server’s 50 maximum connections.

I updated all the configuration to 256 for maximum simultaneous connections. Hope server won’t break down for Comet application from now on.

For more about extreme maximum simultaneous connections, please read articles:


<IfModule prefork.c>
#StartServers 1
#MinSpareServers 1
#MaxSpareServers 5
StartServers 3
MinSpareServers 5
MaxSpareServers 10
#ServerLimit 50
ServerLimit 256
#MaxClients 50
MaxClients 256
MaxRequestsPerChild 4000


<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009"
maxThreads="256" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" protocol="AJP/1.3" />

Posted in Comet, httpd, Tomcat | Comments Off on Maximum Connections for Tomcat, Apache and Comet

How To Replace “/” With “” in .bat File

Here is an example to replace string with a different delimiter in Windows’ *.bat file.

for /f "tokens=1-15 delims=/" %%i in ("%1") do (
set _X1_=%%i
set _X2_=%%j
set _X3_=%%k
set _X4_=%%l
set _X5_=%%m
set _X6_=%%n
set _X7_=%%o
set _X8_=%%p
set _X9_=%%q
set _XA_=%%r
set _XB_=%%s
set _XC_=%%t
set _XD_=%%u
set _XE_=%%v
set _XF_=%%w)
set _XPATH_=%_X1_%
if not "%_X2_%" == "" set _XPATH_=%_XPATH_%\%_X2_%
if not "%_X3_%" == "" set _XPATH_=%_XPATH_%\%_X3_%
if not "%_X4_%" == "" set _XPATH_=%_XPATH_%\%_X4_%
if not "%_X5_%" == "" set _XPATH_=%_XPATH_%\%_X5_%
if not "%_X6_%" == "" set _XPATH_=%_XPATH_%\%_X6_%
if not "%_X7_%" == "" set _XPATH_=%_XPATH_%\%_X7_%
if not "%_X8_%" == "" set _XPATH_=%_XPATH_%\%_X8_%
if not "%_X9_%" == "" set _XPATH_=%_XPATH_%\%_X9_%
if not "%_XA_%" == "" set _XPATH_=%_XPATH_%\%_XA_%
if not "%_XB_%" == "" set _XPATH_=%_XPATH_%\%_XB_%
if not "%_XC_%" == "" set _XPATH_=%_XPATH_%\%_XC_%
if not "%_XD_%" == "" set _XPATH_=%_XPATH_%\%_XD_%
if not "%_XE_%" == "" set _XPATH_=%_XPATH_%\%_XE_%
if not "%_XF_%" == "" set _XPATH_=%_XPATH_%\%_XF_%

For more information, please key in “for /?” in command line.

Posted in Tricks | 1 Comment