& 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.