爪哇岛的一个山洼。

2007-03-29

【技术心得】2007-03-29 凌晨解决 linux 中 java 对中文宋体的支持

2007-03-29 凌晨解决 linux 中 java 对中文宋体的支持

问题产生:我配置在linux上的tomcat服务器生成图片时中文,出现很多小方框,不能正常显示。
问题解决过程:通过网络上搜索资料,发现是因为linux上jre对中文支持的问题。后来发现这篇小文章:
----------------------------------------------------------------------------------------------
JDK 6 for linux的中文问题
在linux下做java开发已经好几年了,经历了jdk1.4 -> 6.0。看着java在linux下的中文问题已经在慢慢改善。到6.0不做任配置都已经能正常运行很多中文程序,但可惜还是会有些中文问题。例如运行 jedit, netbeans等程序。甚至是自己写的hello world swing程序的系统菜单都是乱码的。
但解决方法很简单,在JRE 5以上的java环境中,java会自动加载$JAVA_HOME/jre/lib/fonts/fallback目录下的字体。链接或复制宋体或微软雅黑等字体到该目录即可解决。
但官方文档上说此法只适用于swing程序,要让awt程序也支持中文,还要自己设字体配置文件。由于我很少会用到awt程序,也就懒得去改了,有需要的朋友请参考Font Configuration Files
----------------------------------------------------------------------------------------------
感谢这篇文章的作者,虽然语言不多,但对不知情者很有价值。我按照其中的这句话:
在JRE 5以上的java环境中,java会自动加载$JAVA_HOME/jre/lib/fonts/fallback目录下的字体。链接或复制宋体或微软雅黑等字体到该目录即可解决。
进行操作:
在Windows XP的字体目录下,找到simsun.ttc的字体文件,重命名为simsun.ttf,然后将该文件复制到linux的/usr/local/jdk/jre/lib/fonts/fallback/(这个fallback目录如果不存在则先创建这个目录)下面,因为 simsun.ttf 字体文件对应的是宋体,则在程序中使用的时候设置字体为“宋体”。重新启动tomcat服务,运行程序,中文正确显示。该问题解决。

由于本人之前对linux系统不熟悉,遇到这样的未知问题,但通过搜索资料,很快便解决了这个问题。

2007-03-28

【技术心得】2007-03-28 整理 mysql 在 linux 上面设置中文字符集

2007-03-28 整理 mysql 在 linux 上面设置中文字符集

先从 /usr/local/mysql/support-files/ 目录下面拷贝 my-huge.cnf 或者 my-large.cnf 或者 my-innodb-heavy-4G.cnf 或者 my-medium.cnf 或者 my-medium.cnf 或者 my-small.cnf 到 /etc/ 下面,并命名为 my.cnf,即 /etc/my.cnf(因为mysql默认会在 /etc/my.cnf 下面读取配置)。然后在 /etc/my.cnf 配置文件中加入中文字符的设置:

在[client]下面添加:
#---------------------------------------------------------------------------
# Add by widen on 2007-03-15
default-character-set=gbk
#---------------------------------------------------------------------------

然后在[mysqld]下面添加:
#---------------------------------------------------------------------------
# Add by widen on 2007-03-15
default-character-set=gbk
#---------------------------------------------------------------------------

重新启动mysql服务器,就可以生效了。

遇到mysql问题时的核心解决问题的方法:先到mysql的安装目录查找各种帮助性质的文件,如果不能找到有用信息,则查看mysql详细用户手册,或者到网上搜索相关问题。

2007-03-16

【技术心得】The drawback of AndroMDA

Hi Widen,

Since you mentioned that you used MagicDraw and AndroMDA three times for
projects.
My question is what is the drawback, the most difficulty part when using
both tools during your projects?
How you overcame this drawback for your projects? Any other weakness for
these two tools when you encountered
during your projects?

I think that email may be better than Instant Messanger for the questions.
It is no in the hurry, please reply it whenever you are free. Thanks.

Jack





Hi Jack,

It's a good question. I think AndroMDA is just a tool, so before using it, we must evaluate it all-around with actual development environment.

AndroMDA is a code generation tool that takes a UML model as input and generates source code as output. Using a series of template files (which you can customize if you wish), AndroMDA can produce source code from a UML model in any programming language. Default templates exist to generate Java code (and in particular J2EE code).

There are two primary components used in the AndroMDA system:

1. The AndroMDA code generation engine.
2. Apache's Maven project builder and management system.

As I see, the main drawback of AndroMDA is the complicated configuration, and the costs of study maybe high. when using it, I often meet some errors which I don't know (maybe this is the most difficulty part when using it), and the best solution is going to the support forum ( http://forum.andromda.org/) to search resources and ask questions. the developers are very warmhearted, they answerd all my questions quickly.

Because AndroMDA is just a tool, we should not completely depend on it. It can enhance efficiency when you use it in appropriate place.

2007-03-15

【好文共赏】北京的美好生活

转载一首诗歌,比较有趣,如有雷同,纯属巧合。

远看北京像天堂,近看北京像银行;到了北京像牢房,不如回家放牛羊。
个个都说北京好,个个都往北京跑;北京挣钱北京花,哪有余钱寄回家。
都说这里工资高,害我没钱买牙膏;都说这里伙食好,青菜里面加青草。
都说这里环境好,旺才小强四处跑;都说这里领班帅,个个平头像锅盖。
年年打工年年愁,天天加班像只猴;加班加点无报酬,天天挨骂无理由。
碰见老板低着头,发了工资摇摇头;到了月尾就发愁,不知何年才出头。

2007-03-14

【学习心得】2007-03-14 在linux平台上配置Apache服务器出现问题的解决记录

2007-03-14 在linux平台上配置Apache服务器出现问题的解决记录

今天,我在linux台式机上面配置好Apache2.2.4服务器后,在linux本机使用命令 lynx http://localhost 或者 lynx http://192.168.0.8 测试均显示正确的Apache主页,表示Apache服务器配置成功。但是当我利用局域网内另外一台装有Windows操作系统的机器的浏览器访问 http://192.168.0.8 时,一直不成功。经过查询相关资料,发现 FC6 系统默认的情况下防火墙禁止了外界对 http 服务的访问。因此我在防火墙中将这个 http 的访问权限打开,然后用Windows的机器访问Linux的Apache服务,测试成功。

总之,我遇到的这个问题,原因在于linux系统防火墙设置。

【学习心得】2007-03-14 在linux平台上安装php5出现问题的解决记录

2007-03-14 在linux平台上安装php5出现问题的解决记录

我在 FC6 上成功安装了 httpd-2.2.4.tar.gz 和 mysql-5.0.37-linux-i686.tar.gz 后,我开始安装 php-5.2.1.tar.gz,执行如下命令:

./configure -prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --with-zlib-dir=/usr/lib

在没有加参数 --with-zlib-dir=/usr/lib 之前出现如下错误:
configure: error: Try adding --with-zlib-dir=<DIR>. Please check config.log for more information.

加入参数 --with-zlib-dir=/usr/lib 之后出现如下错误:
configure: error: mysql configure failed. Please check config.log for more information.

通过查阅网上相关资料,最后问题解决。首先参数 --with-zlib-dir=/usr/lib 需要加上,另外是因为 mysql 的版本不兼容的问题,在 mysql 的官方网站上提供了一个 glibc23 的版本,我猜想如果机器上的 glibc 版本大于等于 2.3 的话,可能需要安装这个版本才行,因此我用 rpm -qa | grep glibc 查询,显示如下:
glibc-headers-2.5-3
glibc-common-2.5-3
glibc-devel-2.5-3
glibc-2.5-3
我机器上的 glibc 版本大于 2.3,因此立即重新安装了 mysql-5.0.37-linux-i686-glibc23.tar.gz 的 mysql 版本。此时再次安装 php5 时就一切OK了。总之遇到类似问题的解决办法就是多上网查询资料,多检查版本是否兼容,肯定可以解决的。