How to set JDK Chinese fonts in Linux

Source: Internet
Author: User
& Nbsp; we often find that in Linux, the Chinese characters of java applications will become one by one "ports", which will cause a lot of troubles for our use. But we do not want to give up the convenience of Linux and java. How can we solve this problem? In fact, it is quite easy to solve this problem. First  

We often find that in Linux, the Chinese characters of java applications will become one by one "ports", which will cause a lot of troubles for our use. But we do not want to give up the convenience of Linux and java.

How can we solve this problem?

In fact, it is quite easy to solve this problem.

First, let's talk about the cause of this problem. When the java program is started, the corresponding fonts will be searched in the $ JAVA_HOME/jre/lib/fonts directory for display. Because JDK does not have a Chinese font by default, we need to manually set it so that the java application can find the corresponding Chinese font. This will solve the problem.

Now we have a clear idea, so let's start to solve the problem.

The basic steps are as follows:

1) cd $ JAVA_HOME/jre/lib/fonts

2) mkdir fallback

3) cp xxx. ttf fallback # xxx. ttf indicates the Chinese font file you want.

4) cd fallback

5) mkfontscale

6) mkfontdir

In fact, we can use a command to solve this problem. Connect the Linux font directory as a font directory under JDK.

Ln-s $ FONTS_PATH/FONT_DIR $ JAVA_HOME/jre/lib/fonts/fallback

When you open your java application, you will be able to see long-lost Chinese characters.

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.