How to install JDK in Linux and how to display Chinese Characters

Source: Internet
Author: User

How to install JDK in Linux and how to display Chinese Characters

Do not repost this article without your permission!

Abstract: With Sun's j2se 5.0 release, jdk1.5, the addition of many new features and the improvement of JVM performance are exciting. Windows Installation and environment settings, as well as Chinese display are nothing to say, and it can be said to be silly. However, Linux won't be so smooth, especially the display of Chinese fonts has always plagued novice users. JDK 1.5.0's Chinese display settings have changed significantly compared with j2sdk 1.4.x. This article focuses on the installation of JDK in the Linux operating system, environment variable settings, and solutions to Chinese display problems.

1. First, download the jdk1.5 installation file from sun. There are generally two types.
: Http://java.sun.com/j2se/1.5.0/download.jsp
Linux rpm in self-extracting file (jdk-1_5_0-linux-i586-rpm.bin, 42.50 MB)
Linux self-extracting file (jdk-1_5_0-linux-i586.bin, 43.95 MB)
To put it simply, the difference between the two installation files is that the Linux rpm in self-extracting file is a binary format that encapsulates the RPM installation package in the compressed package. In the command line of the Linux operating system, add the execution permission to the file chmod A + x jdk-1_5_0-linux-i586-rpm.bin, and then. /jdk-1_5_0-linux-i586-rpm.bin can get this RPM package jdk-1_5_0-linux-i586.rpm, after installing RPM package also use more? Rpm? IVH package-name. The advantages of the former are ease of installation and maintenance. The latter is suitable for advanced users. It is equivalent to a "green" JDK of a zip version. There is no installation program. Some links may be required after installation (For details, refer to the JDK installation guide document ). After adding the execution permission to the latter, you can directly execute the binary file to get JDK 1.5.0. In general, the user's habit is to put JDK under/usr/Java, by default, rpm is installed in/usr/Java.
2. After installation, you need to set the environment variables, which can be divided into two different situations.
The first is to set the environment variables for a single user. Modify the. bash_profile file corresponding to the user. We can use VI ~ /. Bash_profile to edit the current user's bash_profile file. Of course, you can also use your favorite editor. Insert the code at the beginning or where appropriate:
Export java_home =/usr/Java/jdk1.5.0
Export classpath =.
Export Path = $ java_home/bin: $ path
Then save the file, log out and log on again, and enter Java in the console? Version. If a message is displayed, the installation setting is successful.
Note: This Code is intended to look simple, so no complicated variable reference is added. Users familiar with shell can modify the code of the second method.
Java version "1.5.0"
Java (TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java hotspot (TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

The second is to set the Linux global environment variable (root permission required), modify/etc/profile, and add the following code in the appropriate place:
Java_home =/usr/Java/jdk1.5.0
Path = $ java_home/bin: $ path
Classpath =.: $ java_home/lib/tools. jar: $ java_home/lib/dt. Jar
Export path java_home classpath
Save the modification. log out of the current user and log on again. Then, perform the test in the same way as the first method to check whether the modification is successful.
Now, the basic installation and environment variable settings are complete.
For how to correctly display the plug-in installation of the applet browser, see Sun's documentation:
Http://java.sun.com/j2se/1.5.0/install-linux.html#plugin
Http://java.sun.com/j2se/1.5.0/manual_install_linux.html
Next we will talk about how to modify the configuration to correctly display the Chinese font.
3. Finally, we can solve the problem of Chinese font display. The font configuration of JDK 1.5.0 differs greatly from that of 1.4.x. First, let's take a look at the display of controlpanel Chinese fonts without any modification,
 
Although Chinese characters can be displayed, most of the boxes cannot be displayed normally. Next we will solve this problem.
Let's take a look at some of Sun's official notes on jre1.5.0 Chinese font settings:
This section describes how to load the font configuration file. The loading sequence is: javahome/lib/fontconfig. OS. version. properties.
Javahome/lib/fontconfig. OS. version. BFC
Javahome/lib/fontconfig. OS. Properties
Javahome/lib/fontconfig. OS. BFC
Javahome/lib/fontconfig. version. Properties
Javahome/lib/fontconfig. version. BFC
Javahome/lib/fontconfig. Properties
Javahome/lib/fontconfig. BFC
The OS field can be:
Windows: "98", "2000", "me", "XP", "2003 ".
Solaris: null.
Linux: "sun", "RedHat", "Turbo", "SuSE ".
The version field indicates the OS version number.
In these configuration files, only the. properties file is a text file. The format is different from that of jre1.4.2. The file is divided into several segments, and the start time of each segment is specified.
We need to focus on only two sections: component font mappings and search sequences. The former specifies the font, and the latter specifies the search sequence of the properties to be used.
With this knowledge, the configuration is simple.
Is it a bit dizzy and useless? Do not rush to use the following.
First put the font file simsun. TTF (copy from windows to Linux) to the JRE Font directory $ java_home/JRE/lib/fonts, and then edit the file fonts under the font directory. dir, add the number in the first line to 1, and then add the following to the last line:
Simsun. TTF-sungtil GB-Medium-r-normal -- 0-0-0-0-c-0-gb2312.1988-0
Save the file.
Finally, rename the fontconfig file. redHat. properties (Fedora Core X is also a derivative of RedHat). Move all the files starting with fontconfig in $ java_home/JRE/lib to the newly created Bak directory, of course, if you do not back up data, you can just ask me not to worry about it.
NOTE: If your Linux is not a RedHat or Fedora Core series, modify the font configuration file according to your release version. For more information, see sun, JDS, Suse, and turbo should be okay. I don't know about Debian and Mandrake. If you have successfully modified them in your own way, please let me know in detail so that I can complete this document.
Then execute controlpanel in the console to check whether it is great!
 
You can also use your own programs to display Chinese fonts perfectly!
 
4. References
Http://addone.blogchina.com/blog/article_17203.216643.html
Sun's official instructions on jre1.5.0 Chinese font settings:
Http://java.sun.com/j2se/1.5.0/docs/guide/intl/fontconfig.html

I have limited capacity. If you have any mistakes or errors, please do not hesitate to advise!

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.