Reprinted from the personal homepage of 滇,, paying lofty respect for the author
JDK1.4: Linux, Java Swing, the default cannot display Chinese characters, there are many introductions on the Internet, but it seems that it is not very detailed, so I think there is still necessary to deactivate these changes and repeat.
First, switch to root using the su command, and then switch to your JDK installation path using the CD command, for example, on my machine, JDK is installed under /usr/java/j2sdk1.4.2_01/.
Then, switch to the JRE / LIB directory in this directory, back up the font.properties:
# cd /usr/java/j2sdk1.4.2_01/# CD jre / lib / # mv font.properties font.properties.bak
Next, font.properties.zh_cn.sun is copied to Font.properties. If there is no font.properties.zh_cn.properties.zh_cn.sun on your machine, it should have "font.properties.zh_cn. Other words". If there is no, then you'd better reload a newer version of JDK.
# cp font.properties.zh_cn.sun font.properties
Finally, edit the replicated font.properties file, jump to the end of the file, find "filename.xxx =", change the back path to the full path where the SIMSUN.TTF on your machine, the following appendedFontPath is also done Corresponding modifications, point the path to the folder where your SIMSUN.TTF is located.
Filename.-hanyi-hanyisong-medium-r-normal - * -% D - * - * - c - * - GBK-0 = / usr / share / fonts / local / simsun.ttfappendedfontpath = / usr / share / fonts / local /
JDK1.5 (this is not easy to find A)
The Java Swing under Linux cannot display Chinese characters by default, and there are many Chinese configurations for JDK 1.4, and the website of the fox has also introduced this. In contrast, the relevant information about the Chinese configuration of JDK 1.5 is more difficult, and the fox is a lot of effort to configure the Chinese display of JDK 1.5, and the configuration process is now described in detail below:
First, switch to root using the su command, then switch to your JDK installation path, for example, JDK is installed on /usr/java/jdk1.5.0_05, on my machine.
Then, switch to the JRE / LIB directory in this directory, you will see that there are many files such as fontconfig. *. Properties.src. Select a Properties that is closest to your system, copy it to fontconfig.properties. For example, my system is Fedora Core, so I will use fontconfig.redhat.properties:
# cp fontconfig.redhat.properties.src fontconfig.properties
Edit Copy the obtained font.properties file, change the Chinese default font in the COMPONENT FONT MAPPINGS block at the beginning to SIMSUN, as follows:
# Component font mappingsallfonts.chinese-cn-iso10646 = -Misc-simsun-medium-r-normal - * -% D - * - * - C - * - ISO10646-1 then adds SIMSUN in Font File Names block Path mapping, change the following path to the path where SIMSUN.TTF in your machine:
# Font file namesfilename.-misc-simsun-medium-r-normal - * -% D - * - * - c - * - ISO10646-1 = / usr / local / share / fonts / simsun.ttf
Finally, jump to the end of the file, point to the corresponding directory of the AWT's font search path:
# AWT X11 font pathsawtfontpath.chinese-tw-iso10646 = / usr / local / share / fontsawtfontpath.chinese-cn-iso10646 = / usr / local / share / fontsawtfontpath.japanese-iso10646 = / usr / local / share / fontsawtfontpath.korean -iso10646 = / usr / local / share / fonts