Author Archives: Zhou Renjian

VMWare Player, Ubuntu and Mac OSX

So you want to play some other operating systems for some new features, or test your applications on other OSs? Take a try on VMWare Player. It is free.

Along with downloading and installing VMWare, you should also download OS images ( also called as Virtual Applicances). I think you should not miss Ubuntu 8.04 Desktop image (512M). I found that Ubuntu 8.04 running quite smoothly inside VMWare on my laptop with duo-core 2.2Ghz CPU and 2G memory. And I am lazy to install GIMP on my Vista, so running GIMP for some graphic manipulations may be one of Ubuntu jobs. And developing C++ or Java applications inside Ubuntu may be another job for me. And lots of other testing jobs. So owning an Ubuntu desktop is necessary.

(But I find a big inconvenience in my Ubuntu. I can input anything but having great difficulties in inputting 5 characters: “, ‘, ~, `, ^. I need to press that key and follow a space key to input these characters. I struggled hours to fix it but failed. So if you need a solution, please be kind to inform me.)

By the way, why not taking a try on Mac OSX Leopard. Download its 3.3G (expanded to 8G) Mac OSX Leopard x86 image (You should know that it is a pirate copy), following its instructions to install and patch. As using VMWare Player, you have to modify *.vmx directly to load *.iso patch into Leopard:

ide1:0.fileName = “D:\Downloads\Maxxuss-AMDPCNET-v1.0_1043.iso”
ide1:0.deviceType = “cdrom-image”

And you may also change

guestOS = “freebsd-64”

to

guestOS = “freebsd”

So no 64-bit CPU warning in starting this x86 Mac copy.

Well, I feel little excitement to Leopard as it is too slow. So maybe it is just for feature peeking or some small tests. It is not ready for daily work. Hope you have enough patience for the 2-3 days’ image download time and 12G hard disk spaces wasting.

Posted in Tricks | Tagged , , , | 2 Comments

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]
“ColorDepth”=dword:00000004

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]
“ColorDepth”=dword:00000004

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

References:
http://www.j79zlr.com/gphome.php

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/libnspr4.so .
ln -s /usr/lib/libnss3.so .
ln -s /usr/lib/libnssckbi.so .
ln -s /usr/lib/libplc4.so .
ln -s /usr/lib/libplds4.so .
ln -s /usr/lib/libsmime3.so .
ln -s /usr/lib/libsoftokn3.so .
ln -s /usr/lib/libssl3.so .
ln -s /usr/lib/libfreebl3.so .
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 AccJSample.java Prefs.java
java -cp ../../dist/release/accjwrap.jar:./ AccJSample username password developerkey

But you may get error messasge like:

UNKNOWNVALUE
com.aol.acc.AccException: IAccSession_SignOn
at com.aol.acc.AccSession.SignOn(Native Method)
at com.aol.acc.AccSession.signOn(AccSession.java:113)
at AccJSample.(AccJSample.java:47)
at AccJSample.main(AccJSample.java:22)

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 catalina.sh and add two lines:

LD_LIBRARY_PATH=$CATALINA_HOME/bin
cd $CATALINA_HOME/bin

And then restart Tomcat server.

Related links:

Posted in Java, Tomcat | Tagged | 10 Comments

JavaCC

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 javacc-4.0.zip 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
workspace\.metadata\.log
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
workspace\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes
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 xxx.xxx.xxx.xxx –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:
http://jha.rajeev.googlepages.com/web2push
http://www.stdlib.net/~colmmacc/Apachecon-EU2005/scaling-apache-handout.pdf

http.conf

<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
</IfModule>

server.xml

<!-- 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