Saturday, October 22, 2005

Sensei's Library: KGS Issue - Asian Fonts

Sensei's Library: KGS Issue - Asian Fonts
This article provides a detailed solution for chinese and CJK charactor's display problem in Java.

Friday, October 21, 2005

Icons - borrowed from Eclipse

create the following shell bash file for the eclipse icons

#!/bin/sh

CVSROOT=:pserver:anonymous@dev.eclipse.org:/home/eclipse
export CVSROOT

mkdir -p eclipse
cd eclipse
cvs -q co org.eclipse.debug.ui/icons
cvs -q co org.eclipse.pde.ui/icons
cvs -q co org.eclipse.jdt.ui/icons
cvs -q co org.eclipse.vcm.ui/icons
cvs -q co org.eclipse.team.ui/icons
cvs -q co org.eclipse.ant.ui/icons
cvs -q co org.eclipse.help.ui/icons
cvs -q co org.eclipse.ui/icons
cvs -q co org.eclipse.ui.views/icons
cvs -q co org.eclipse.ui.console/icons
cd ..
rm -f ~/public_html/eclipse-icons.zip
find eclipse -name "*.gif" -print | zip ~/public_html/eclipse-icons.zip -@

Use JavaMail in the Geronimo application server

Use the eclipse for the ide, and use maven as the site building engine. Update the mavenide in eclipse, using the following update site:
http://mevenide.codehaus.org/release/eclipse/update/site.xml

String code in Java

How to read the UTF-8 string correctly, if currently locale is not UTF-8:
Use the getBytes:
strInput.getBytes("UTF-8")
And you can wrap it in the input stream, for example:
new ByteArrayInputStream(strInput.getBytes("UTF-8"))

Thursday, October 20, 2005

成为Eclipse热键高手(zz)

几个相关的小窍门:

  锁定命令行窗口:在命令行视图中(Window Show View Other Basic Console),试试看用滚动锁定按钮来锁定控制台输出不要滚屏。

  使用Ant视图:在我的Java或Debug模式下,我喜欢显示出Ant视图,这样我就可以迅速的运行Ant任务。通过Window  Show View  Other  Ant可以找到该视图。把Ant视图放在屏幕的一角, 通过“添加编译文件(Add Buildfiles)”按钮来添加build.xml文件。在3.1版本中,甚至支持Ant调试脚本语言。

  自动遍历一个集合:for + Control-Space: 如果你还不知道,那么你应该记住Control-Space是自动完成功能。在Eclipse中,你还可以自动完成结构。在一个数组或集合范围内,试试看输入“for”然后按下Control-Space键。Eclipse会问你你想要遍历哪一个集合然后自动完成循环代码。

  使用分级布局:在包浏览视图(Package Explorer view)中默认的布局(扁平式)方式让我困惑,它把包的全名显示在导航树(navigation tree)中。我更喜欢我源码的包和文件系统视图,在Eclipse中叫做分级布局(Hierarchical Layout)。要切换到这种模式,点击包浏览视图中向下的按钮,选择布局(Layout),然后选择分级(Hierarchial)。

  一次显示多个文件:你可以一次浏览多个文件。把不在激活状态的编辑窗口拖到激活窗口的底部或侧边的滚动条上,就可以打开该编辑窗口。这是我能描述该窍门的最好方式了。

  同时打开两个Eclipse:要将改动从一个CVS分支上合并到另外一个上,我喜欢通过同时打开两个工作目录(Workspace)不同Eclipse来实现。这样我可以通过比较CVS上的最新版本看到所有的变化(右键单击工程,然后选择Compare with  Lastest from HEAD)然后把每一个变化都合并到另外一个CVS分支上。启动多个Eclipse的最简单的方法是利用Eclipse Launcher。

  Implementors插件:安装一个能够跳到一个接口的实现的插件。如果你是个dependency injection 粉丝,或者正在基于编写优良的接口工作,那么你需要一个这样的插件来加速代码导航。 你可以在SourceForge找到这个插件。

Wednesday, October 19, 2005

MySQL user password and privilege setup

Default user name and password for MySQL: root, mysql
Methods to add or change user's password
1. phpMyAdmin: The php frontend. Use SQL to update the user database directly. Don't forget to use the function password(strPassword) to encrypt the password.
2. On the console:
>mysqladmin -u root -pold password newpasswd
3. mysql> INSERT INTO mysql.user (Host,User,Password) VALUES ('%','system', PASSWORD('newpasswd'));
 mysql> FLUSH PRIVILEGES
4. mysql> REPLACE INTO mysql.user (Host,User,Password) VALUES('%','system',PASSWORD('newpasswd'));
 mysql> FLUSH PRIVILEGES
5. mysql> SET PASSWORD FOR system@"%" = PASSWORD('newpasswd');
6. mysql> GRANT USAGE ON *.* TO system@"%" IDENTIFIED BY 'newpasswd';

The method to setup the privilege in MySQL
mysql>GRANT ALL PRIVILEGES ON *.* TO system@localhost IDENTIFIED BY 'newpasswd' WITH GRANT OPTION;

Saturday, October 15, 2005

XML parser's java.lang.LinkageError in maven

from: http://blog.nona.name/archives/143.html
ava.lang.LinkageError: loader constraints violated when linking org/w3c/dom/Document class

这个问题比较诡异。在JdK1.4以上使用maven test的时候
如果涉及到XML的解析就会出错。没搞明白怎么回事。

解决方法是设定:maven.junit.fork = true
“When using Java 1.4, it may be necessary to fork the JUnit tests to prevent XML parser issues. The default value is no. ”

See also http://maven.apache.org/faq.html#unit-test-14

Saturday, October 08, 2005

font configuration for font errors UTF-8 pages

modify the font file in "/etc/fonts/fonts.conf", change your favored chinese font's priority.

Monday, October 03, 2005

provide sound support for frozen-bubble and many other games

sudo apt-get install libsdl1.2debian-all