用户操作
[留言]  [发消息]  [加为好友] 
订阅我的博客
XML聚合    FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
fadestarfish的公告
<table width="100%" border="0"> <tr> <td align="center"> <img src="http://blog.csdn.net/images/blog_csdn_net/fadestarfish/71796/t_1.jpg"> </td> </tr></table> <br> <!-- Blog日历表开始 --> <script language="javascript"> var diarydays="<2004-08-05><2004-08-09><2004-08-12><2004-08-17><2004-08-19><2004-07-14><2004-07-13><2004-07-08><2004-07-05><2004-07-04><2004-07-03><2004-06-27><2004-06-26><2004-06-25>"; </script> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <style> .calendarBigBorder { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; text-decoration: none; width: 170; background-color: #FFFFFF; font-size: 9pt;border:1px dotted #999; } .calendarTd { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; font-size: 9pt; color: #000000; background-color: #eeeeee; height: 18px; width: 11%; text-align: center;} .calendarMInput { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; font-size: 9pt; text-decoration: none; background-color: #FFFFFF; height: 15px; border: 1px solid #666666; width: 19px; color: #0099FF;} .calendarYInput { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; font-size: 9pt; color: #0099FF; text-decoration: none; background-color: #FFFFFF; height: 15px; width: 34px; border: 1px solid #666666;} .calendarMonthTitle { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; font-size: 9pt; font-weight: normal; height: 24px; text-align: center; color: #333333; text-decoration: none; background-color: #eeeeee; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-bottom-style: none; border-top-color: #999999; border-right-color: #999999; border-bottom-color: #999999; border-left-color: #999999;} .calendarNow { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; font-size: 9pt; font-weight: bold; color: #000000; background-color: #C0C9D3; height: 18px; text-align: center;} .calendarDaySat { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; font-size: 9pt; color: #333333; text-decoration: none; background-color: #eeeeee; text-align: center; height: 18px; width: 12%;} .calendarDaySun { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; font-size: 9pt; color: #333333; text-decoration: none; background-color: #eeeeee; text-align: center; height: 18px; width: 12%;} .calendarLink { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; font-size: 9pt; font-weight: normal; color: #333333; text-decoration: none; background-color: #E7E7F6; text-align: center; height: 18px;} .categoryTxt { font-family: "Arial", "Helvetica", "sans-serif", "宋体"; font-size: 9pt; line-height: 23px; color: #333333; text-decoration: none;} .categoryTable { border-right-width: 1px; border-bottom-width: 1px; border-right-style: solid; border-bottom-style: solid; border-left-style: none; border-right-color: #000000; border-bottom-color: #000000; border-top-width: 1px; border-top-style: solid; border-top-color: #71b99c;} </style> <SCRIPT LANGUAGE="JavaScript"> var months = new Array("一", "二", "三","四", "五", "六", "七", "八", "九","十", "十一", "十二"); var daysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31,30, 31, 30, 31); var days = new Array("日","一", "二", "三","四", "五", "六"); var classTemp; var calendarHover="calendarHover"; var today=new getToday(); var year=today.year; var month=today.month; var newCal; //得到某月天数 function getDays(month, year) { if (1 == month) return ((0 == year % 4) && (0 != (year % 100))) ||(0 == year % 400) ? 29 : 28; else return daysInMonth[month]; } //得到当天时间信息 function getToday() { this.now = new Date(); this.year = this.now.getFullYear(); this.month = this.now.getMonth(); this.day = this.now.getDate(); } //生成日历 function Calendar() { newCal = new Date(year,month,1); //当前月的第一天 today = new getToday(); var day = -1; //用来判断日历中是否为当天 var startDay = newCal.getDay(); //当月开始时间 var endDay=getDays(newCal.getMonth(), newCal.getFullYear());//当月结束时间 var daily = 0; //用来生成日历中的天数值 if ((today.year == newCal.getFullYear()) &&(today.month == newCal.getMonth())) day = today.day; var caltable = document.all.caltable.tBodies.calendar; //得到日历表格的集合 var intDaysInMonth =getDays(newCal.getMonth(), newCal.getFullYear()); //得到当月天数 //生成日历 for (var intWeek = 0; intWeek < caltable.rows.length;intWeek++) for (var intDay = 0;intDay < caltable.rows[intWeek].cells.length;intDay++) { var cell = caltable.rows[intWeek].cells[intDay]; //得到单元袼 //生成字符串用于判断当天是否有日志 var montemp=(newCal.getMonth()+1)<10?("0"+(newCal.getMonth()+1)):(newCal.getMonth()+1); if ((intDay == startDay) && (0 == daily)){ daily = 1;} var daytemp=daily<10?("0"+daily):(daily); var d="<"+newCal.getFullYear()+"-"+montemp+"-"+daytemp+">"; //选择样式 if(day==daily) cell.className="calendarNow"; else if(diarydays.indexOf(d)!=-1) cell.className="calendarLink"; else if(intDay==6) cell.className = "calendarDaySat"; else if (intDay==0) cell.className ="calendarDaySun"; else cell.className="calendarTd"; //生成值 if ((daily > 0) && (daily <= intDaysInMonth)) { cell.innerText = daily; daily++; } else cell.innerText = ""; } document.all.year.value=year; document.all.month.value=month+1; } function subMonth() { if ((month-1)<0) { month=11; year=year-1; } else { month=month-1; } Calendar(); } function addMonth() { if((month+1)>11) { month=0; year=year+1; } else { month=month+1; } Calendar(); } //得到响应事件 function getDiary() { var mon=(newCal.getMonth()+1)<10?("0"+(newCal.getMonth()+1)):(newCal.getMonth()+1); var day=event.srcElement.innerText<10?("0"+event.srcElement.innerText):(event.srcElement.innerText); var d="<"+newCal.getFullYear()+"-"+mon+"-"+day+">"; if ("TD" == event.srcElement.tagName) if (("" != event.srcElement.innerText)&&(diarydays.indexOf(d)!=-1)) { diary.location="/foxmail/archive/"+newCal.getFullYear()+"/"+mon+"/"+day+".aspx"; window.location.href = diary.location; } } function setDate() { if (document.all.month.value<1||document.all.month.value>12) { alert("月的有效范围在1-12之间!"); return; } year=Math.ceil(document.all.year.value); month=Math.ceil(document.all.month.value-1); Calendar(); } </SCRIPT> <table border="0" cellpadding="0" cellspacing="1" class="calendarBigBorder" id="caltable" width="200"> <thead> <tr align="center" valign="middle"> <td colspan="7" class="calendarMonthTitle"> <input name="year" type="text" class="calendarYInput" size="3" maxlength="4" onkeydown="if (event.keyCode==13){setDate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onpaste="this.value=this.value.replace(/[^0-9]/g,'')">年 <input name="month" type="text" class="calendarMInput" size="1" maxlength="2" onkeydown="if (event.keyCode==13){setDate()}" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" onpaste="this.value=this.value.replace(/[^0-9]/g,'')">月 [<a onClick="addMonth()" href="javascript:;">下月</a>] [<a onClick="subMonth()" href="javascript:;">上月</a>]</td> </tr> <tr align="center" valign="middle"> <SCRIPT LANGUAGE="JavaScript"> document.write("<TD class=calendarDaySun id=diary>" + days[0] + "</TD>"); for (var intLoop = 1; intLoop < days.length-1; intLoop++) document.write("<TD class=calendarTd id=diary>" + days[intLoop] + "</TD>"); document.write("<TD class=calendarDaySat id=diary>" + days[intLoop] + "</TD>"); </SCRIPT> </TR> </thead> <TBODY border=1 cellspacing="0" cellpadding="0" ID="calendar" ALIGN=CENTER ONCLICK="getDiary()" onmouseup=document.selection.empty() oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onbeforecopy="return false" oncopy=document.selection.empty() onselect=document.selection.empty()> <SCRIPT LANGUAGE="JavaScript"> for (var intWeeks = 0; intWeeks < 6; intWeeks++) { document.write("<TR style='cursor:hand'>"); for (var intDays = 0; intDays < days.length;intDays++) document.write("<TD class=calendarTd onMouseover='{classTemp=this.className;this.className=calendarHover}' onMouseOut='this.className=classTemp'></TD>"); document.write("</TR>"); } </SCRIPT> </tbody> </table> <script LANGUAGE="JavaScript"> Calendar(); </script> <!-- Blog日历表结束 --> <br> <!-- 天气预报 注意这里涉及到编码问题,%B1%B1%BE%A9为城市代码,可用百度查一下,比如输入北京,地址栏中就会出现%B1%B1%BE%字样的内容--> <center><iframe width=157 height=240 frameborder=0 scrolling=NO src='http://appnews.qq.com/cgi-bin/news_qq_search?city=%C9%CF%BA%A3'></iframe></center> <br> <!-- 显示msn在线状态,注意:必须在msn中设置允许所有人查看你的状态才有效,否则msn图标永远发灰 --> &nbsp;&nbsp;MSN:<A HREF="http://snind.gotdns.com:8080/message/msn/fadestarfish1@hotmail.com"> <IMG SRC="http://snind.gotdns.com:8080/msn/fadestarfish1@hotmail.com" align="absmiddle" border="0" ALT="fadestarfish1@hotmail.com" onerror="this.onerror=null;this.src='http://snind.gotdns.com:8080/image/msnunknown.gif';">
文章分类
Linux和Unix
chinaunix.net
程序设计
Java视线论坛--介绍Hibernate
ChinaJavaWorld.com技术论坛
Java研究组织
java研究组织论坛
Matrix
中国Java开发网
论坛
中国 XML论坛
霏凡论坛
龙族联盟论坛
软件下载
518软件下载
BT下载
搜索软件吧
体育
华体网
音乐
八音盒
在线文档
IBM中国
JDK1.4在线文档
PHP在线手册
Postgres中文网站
Postgres在线文档
Struts标签库
The J2EE 1.4 Tutorial
词霸在线翻译
存档

原创  Java , Installanywhere 在 Redhat 上的中文问题解决方法(转载) 收藏

在 sun jdk /jre 的多个版本中,对于 Redhat 上的中文支持一直是非常糟糕。对于默认安装(不修改任何配置文件)、Java 代码中使用默认字体(不使用 setFont )的情况下,中文汉字总是出不来。在 windows 和 solaris 上则比较少出现这种情况。

有一种说法是 Sun 和 Redhat 是某种竞争关系,对于 Sun 公司来说,只要 Java 在 Solaris 和 Windows 上能够跑,其他操作系统都是多余的;只要 Java 在Solaris 上运行比在 Windows 上运行更好, Windows 也是多余的。正是这种敌视的态度,使得 Java 在非 Solaris 的操作系统上使用时要么中文不能出来,要么极其难看。

不管这种说法是否属实,Sun 没有解决 Java 在 Redhat 上的中文问题,给很多 Java 程序员带来极大的不便。 Sun 自己的网站上也有很多人问到这个问题,但是很少有人提供较好的解决方法,让人感到遗憾。

前一阵子我在使用 Installanywhere 制作在 Redhat 上运行的安装程序时,中文安装界面老是方块块,我将 Installanywhere 网站上所有的 Java VM 逐个试了一遍还是不行,我将 Installanywhere 网站上的讨论组基本上全部看过来,还是找不到解决方法,令我简直怀疑自己的智商。因此下决心查查 Java 在 Redhat 上的中文问题。

我首先向 Installanywhere 的中国一个代理商问起这个问题,他支支吾吾,只是说 Installanywhere 一定支持 Redhat 上的中文安装程序制作。多次电话来往后,我大概听明白了, Sun 不太希望 Installanywhere 在 Redhat 上有较好的表现,所以 Installanywhere 他们不能在网站上公开解决方法,他推荐我们用 Solaris。我说我们用不起 Solaris,然后就没有实质的进展。

我在 google 、中文 yahoo 上搜索了好几个星期都没有结果,但是有了一些资料。后来我到 Redhat 公司网站上搜索,又找到了一些资料。然后自己试了几次,终于搞定。

标准 jre/jdk 中只带了 redhat 6 的 font.properties, 我在 redhat 7.3 和 redhat 8.0 上都不能用。我们需要建一个 font.properties.zh.Redhat 放在 redhat 的 jre/lib 目录下。打开 /usr/lib/X11/fonts/ttf-zh 或者 /usr/share/fonts/zh_CN/TrueType 下面的 font.dir, 将其中的一个中文字体名复制下来,比如 -misc-ZYSong18030-medium-r-normal--0-0-0-0-c-0-iso10646-1,按照 java 的字体规则改为 -misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1,将 font.properties.zh 中的内容复制到 font.properties.zh.Redhat 中。

我选用字体 -misc-ZYSong18030-medium-r-normal--0-0-0-0-c-0-iso10646-1 是因为在 redhat 7.3 和 redhat 8.0 上都能用。

因为 jre/jdk 找不到 Redhat 的 true type 字体,在文件 font.properties.zh.Redhat 最后加入

appendedfontpath=/usr/lib/X11/fonts/ttf-zh
appendedfontpath=/usr/share/fonts/zh_CN/TrueType

将字体名全部替换成 -misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1,替换后的 font.properties.zh.Redhat 如下:

# @(#)font.properties.zh.Redhat.linux 1.4 02/06/10
#
# Copyright 2002 Sun Microsystems, Inc. All rights reserved.
#

# Component Font Mappings
#
serif.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

serif.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

serif.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

serif.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

sansserif.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

sansserif.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

sansserif.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

sansserif.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

monospaced.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

monospaced.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

monospaced.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

monospaced.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialog.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1


dialog.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialog.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialog.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialoginput.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialoginput.italic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialoginput.bold.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

dialoginput.bolditalic.0=-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1
# Missing Glyph Character
#
default.char=274f

# Component Font Character Encodings
#
fontcharset.serif.0=sun.io.CharToByteISO8859_1
fontcharset.serif.1=sun.awt.motif.CharToByteX11GBK

fontcharset.sansserif.0=sun.io.CharToByteISO8859_1
fontcharset.sansserif.1=sun.awt.motif.CharToByteX11GBK

fontcharset.monospaced.0=sun.io.CharToByteISO8859_1
fontcharset.monospaced.1=sun.awt.motif.CharToByteX11GBK

fontcharset.dialog.0=sun.io.CharToByteISO8859_1
fontcharset.dialog.1=sun.awt.motif.CharToByteX11GBK

fontcharset.dialoginput.0=sun.io.CharToByteISO8859_1
fontcharset.dialoginput.1=sun.awt.motif.CharToByteX11GBK

# Exclusion Ranges
#

# XFontSet Information
#
fontset.serif.plain=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.serif.italic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.serif.bold=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.serif.bolditalic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.sansserif.plain=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.sansserif.italic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.sansserif.bold=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.sansserif.bolditalic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.monospaced.plain=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.monospaced.italic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.monospaced.bold=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.monospaced.bolditalic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialog.italic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialog.bold=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialog.bolditalic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialog.plain=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialoginput.italic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialoginput.bold=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialoginput.bolditalic=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

fontset.dialoginput.plain=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

#fontset.default=\
#-b&h-lucida-medium-r-normal-sans-*-%d-*-*-p-*-iso10646-1,\
#-tlc-song-medium-r-normal--*-%d-*-*-c-*-gbk-0

fontset.default=\
-misc-ZYSong18030-medium-r-normal--*-%d-*-*-c-*-iso10646-1

appendedfontpath=/usr/lib/X11/fonts/ttf-zh
appendedfontpath=/usr/share/fonts/zh_CN/TrueType

使用 Installanywhere 我们编译安装程序选择 “其它 java 平台” 编译成一个 java 的 setup.jar 文件,在 Redhat 上面写一个批处理/脚本文件, set classpath , 包含 setup.jar, 批处理/脚本文件中使用 java install 启动安装程序。

这个方法在 redhat 7.3/ 8.0 下面测试通过。

对于 Redhat 上面的繁体中文依法炮制即可,建立 font.properties.zh_TW.Redhat 文件,将其中的字体名改为一个繁体中文字体名,在文件末尾加上合适的 appendedfontpath ,当然最后不要忘了在 Redhat 7.3 和 8.0 下面都测试一遍。

Linux 的不同版本配置方法不一样。主要是因为 Linus Torvalds 等有说话分量的人只专注在 Linux 内核开发上。如果他们对于其他方面略做规划,Linux 的不同版本差别不至于像现在这么大。在 Java + Linux 的使用过程中,我们深深地体会到了 “Write once, debug everywhere” 的苦处。

发表于 @ 2004年12月30日 18:49:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:『时尚资讯』 [家居美食]超赞的美食摄影+作法(转载) | 新一篇:postgresql在win上的安装

  • 发表评论
  • 评论内容:
  •  
Copyright © fadestarfish
Powered by CSDN Blog