Configure the Java environment In Debian

Source: Internet
Author: User
Debian: configure the Java environment-Debian information for the Linux release. For more information, see. Install
Debian does not officially maintain specialized Java software packages, so it cannot be directly installed using apt-get. To install Java in the Debian system, you can install Java in either the traditional method or the Debian method. The following sections describe:

Traditional methods:
Go to SUN official website to download the latest jre package, I downloaded the jre-1_5_0_01-linux-i586.bin, and the file property changed to executable, directly execute the file.

Debian :~ /Inst # chmod + x jre-1_5_0_01-linux-i586.bindebian :~ /Inst #./jre-1_5_0_01-linux-i586.bin

After the program runs, a directory named jre1.5.0 _ 01 is generated under the current directory.

Copy the directory to/usr/local/jre1.5.0 _ 01 and add the following two environment variables to your system initialization script. In my system, I put these two sentences in ~ /. In the gnomerc file.

Export CLASSPATH = "/usr/local/jre1.5.0 _ 01/lib" export JAVA_HOME = "/usr/local/jre1.5.0 _ 01"

After you restart the system or manually execute the preceding two export commands, you can use the java command. You can use the java-version command for testing. Java installed in the traditional way is not integrated into the Debian software package system, so there is no java dependency information in the Debian Software Package database. The Debian software package management program cannot be used for management and can only be manually maintained. That is to say, if we want to delete java, we can only manually delete directories and environment variables.

Debian method (recommended ):
We can use the make-jpkg program provided by the java-package to generate a Debian software package from SUN's official java software package. You can use the apt-get command to install the java-package.

Debian :~ # Apt-get install java-package

Download the official java software package and use the following command to generate a java software package in Debian format. Note that the make-jpkg program cannot run in the root environment. We need to use the fakeroot program.

Debian ~ : # Cp jre-1_5_0_01-linux-i586.bin/home/jims/. debian ~ : # Chown jims/home/jims/jre-1_5_0_01-linux-i586.bindebian ~ : # Su-jimsjims @ debian :~ $ Fakeroot make-jpkg jre-1_5_0_01-linux-i586.bin

After the program is completed, a Debian Software Package sun-j2re1.5_1.5.0 + update01_i386.deb will be generated in the current directory.

Install the software package as root.

Debian ~ : # Dpkg-I sun-j2re1.5_1.5.0 + update01_i386.deb

Finally, set the java environment variable.

Export CLASSPATH = "/usr/lib/j2re1.5-sun/lib/" export JAVA_HOME = "/usr/lib/j2re1.5-sun /"

Use java-version for testing. Java installed in this way stores the relevant information of the java software package in the Debian Software Package database and can be managed using the apt-get tool. To delete java, run the following command.

Debian :~ # Apt-get -- purge remove sun-j2re1.5

We recommend that you use the Debian method to install java, so that other Debian software packages dependent on Java can be installed normally.

Set Chinese display for JAVA
In Linux, if the font of Java is incorrect, the Java program displays Chinese characters as box symbols or question marks. To enable the Java-based program to display Chinese characters properly, you need to configure the font. The following is the configuration method in the Debian environment. The modification method for other releases is the same, but the path name of the file to be modified is different.

Find the ../jre/lib/directory. On my debian system, it is/usr/lib/j2se/1.4/jre/lib. This directory contains many files starting with font, in which font. properties is the default font configuration file of java. Use font. properties. zh_CN.Sun to overwrite the original font. properties file.

Modify the new font. properties file. Take the SimSum font as an example.

Serif.0 =-B & h-lucidabright-medium-r-normal -- *-% d-*-p-*-iso8859-1serif.1 =-Hanyi-HanyiSong-medium-r-normal -- *-% d-*-c-*-gbk-0

Change

Serif.0 =-B & h-lucidabright-medium-r-normal -- *-% d-*-p-*-iso8859-1serif.1 =-misc-SimSun-medium-r-normal -- *-% d-*-c-*-gb2312.1980-0

Set all fonts in the file in the same way as above. If you do not know the fonts installed on your machine, you can use the xlsfonts command to list them.

The above settings apply to java 1.4, And the font settings of java 1.5 are greatly changed. The fontconfig file name is changed to fontconfig. properties. After testing, there are two ways to set the Chinese font in 1.5, one is the same as the 1.4 method, you need to configure the fontconfig. properties file. There are many configuration source files ending with. src in the/usr/lib/j2re1.5/lib directory, representing the standard configuration on different platforms. We can copy them as fontconfig. properties. Then, configure the font name and font file path based on the X11 core Chinese font installed in your system. The second method is very simple. You only need to create a fallback directory under the/usr/lib/j2re1.5/lib/fonts directory and copy or link the Chinese font file to the directory, you do not need to configure anything else.
Related Article

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.