Summary of some issues displayed in Chinese in the Java program in Linux

Source: Internet
Author: User

This generally refers to applications, not web apps. (or statistical graphs generated in Web apps)

General processing principles: 1. There are Chinese fonts 2. JRE can find Chinese fonts 3. Font. properties. xx. xx and your system correctly match

Take Red Hat Enterprise Linux as Release 3 (taroon Update 2), lang = zh_cn.gb18030, JDK 1.4.2 _ 02 as an example.

(If you want to change your situation, do not copy it. For example, if you do not copy the content below, you will not be able to copy it)

1. Chinese fonts/usr/share/fonts/zh_cn/TrueType are found

2. the lib directory of JRE contains font. properties. zh_cn.redhat8.0, but my RedHat is not 8.0. If it is changed to RedHat, it should be generic, So copy it to font. properties. zh_cn.redhat: Check the content and find that the Chinese font has been set in it. The last line also specifies the path of the Chinese font, so you don't need to modify anything.

3. Restart the program/or webserver. OK indicates that the program is successfully restarted.

 

 

% %

The following content is excerpted from various places.

1. Mandrake Linux 8.2 and JDK 1.4.1 (Author: Home cat ])

========================================================== ========

Many of my friends found that Chinese characters are not displayed normally when developing applications using Java in Linux, and Chinese characters in the application in the window are displayed as a string of squares. This is mainly because the font settings are incorrect. In the configuration file that comes with JDK, the specified Chinese font does not exist, leading to incorrect display. This article takes Mandrake Linux 8.2 and JDK 1.4.1 as examples to briefly introduce how to set up the Java Chinese environment in Linux. For other Linux systems or JDK versions, see this article.

First, check whether your/usr/share/fonts/TTF/GB directory contains the Chinese font gbsn00lp. TTF. If not, use song. TTF in the Windows Font directory. Copy the font file to JRE/lib/fonts in the Java installation directory.

Second, modify the JRE/lib/fonts. dir file in the Java installation directory, change 72 in the first line to 73, and then add the following content:

Gbsn00lp. TTF-arphic Technology Co.-ar PL sungtil GB-Medium-r-normal -- 0-0-0-0-c-0-gb2312.1980-0

Note: If you use song. TTF, change gbsn00lp. TTF in the header to song. TTF.

Third, copy the font. properties. Zh. Turbo file to font. properties. ZH In the JRE/lib directory under the Java installation directory. Then modify font. properties. Zh. Put all of the files:

-Replace the-TLC-song-Medium-r-normal -- *-% d-*-C-*-gbk-0:
-Arphic Technology Co.-ar PL sungtil GB-Medium-r-normal -- 0-0-0-0-c-0-gb2312.1980-0

Fourth, use the demo program swingset2 that comes with JDK to test. If the Chinese menu is displayed, the setting is successful.

========================================================== ========

2.Java and installanywhere solutions to Chinese problems on RedHatJacklondon [original]

Only the font. Properties of RedHat 6 is included in the standard JRE/JDK. I cannot use both RedHat 7.3 and RedHat 8.0. We need to create a font. properties. Zh. RedHat and put it in the JRE/lib directory of RedHat. Open/usr/lib/X11/fonts/TTF-ZH or font under/usr/share/fonts/zh_cn/TrueType. dir, copy one of the Chinese characters, such as-misc-ZYSong18030-medium-r-normal -- 0-0-0-0-c-0-iso10646-1, change to-misc-ZYSong18030-medium-r-normal -- *-% d-*-C-*-iso10646-1 according to the font rules of Java. properties. copy the content in ZH to font. properties. zh. in RedHat.

I chose the font-misc-ZYSong18030-medium-r-normal -- 0-0-0-0-c-0-iso10646-1 because it can be used on Redhat 7.3 and RedHat 8.0.

Because JRE/JDK cannot find the true type font of RedHat, add it at the end of the file font. properties. Zh. RedHat.

Appendedfontpath =/usr/lib/X11/fonts/TTF-ZH
Appendedfontpath =/usr/share/fonts/zh_cn/TrueType

Replace all body names with-misc-ZYSong18030-medium-r-normal -- *-% d-*-C-*-iso10646-1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.