Install the Java environment In debian

Source: Internet
Author: User
Install the Java environment In debian-general Linux technology-Linux programming and kernel information. The following is a detailed description. Abstract:
This document is a reference document for installing Java Development Kit (JDK/J2SDK) On Debian GNU/Linux systems.
Due to license issues, SUN's Java system cannot be provided directly in Debian. Therefore, the method for installing Java is provided here for your reference.

1. Get sun's JDK
You can choose to download from Java official: http://java.sun.com or another website

JRE (J2RE)

Java Runtime Environment-if you do not want to create a Java application by yourself, just install it.

JDK (J2SDK)

Java Development Kit-Java software open tool. If you need to create your own Java application, you need to select JDK.


The latest version is:

JDK: jdk-1_5_0_06-linux-i586.bin

JRE: jre-1_5_0_06-linux-i586.bin


Note: The SDK already contains the JRE. JDK is used as an example below.


2. Build a Packaging Environment
Fortunately, Debian provides us with the SDK's DEB package build tool: java-package


# Apt-get install-u java-package fakeroot


Note: update the package list before installation.

3. Create a. deb Software Package
Run as a common user:


$ Fakeroot make-jpkg jdk-1_5_0_06-linux-i586.bin


In this process, there may be some warning information and some necessary options. After a few minutes, the prompt that the software package is successfully created should appear. Congratulations, you will find something similar in the current directory:
Sun-j2sdk1.5_1.5.0 + update06_i386.deb
Software Package

4. Installation
Switch to the root user and run the following command:


# Dpkg-I sun-j2sdk1.5_1.5.0 + update06_i386.deb


Of course, you should specify the correct software package name as needed. This is easy to do. Check the current directory.

5. Configure the environment
In/etc/profile (or ~ /. Bashrc) Add the following content to the script file:


PATH = $ PATH:/usr/lib/j2sdk1.5-sun/bin:/usr/lib/j2sdk1.5-sun/jre/bin
JAVA_HOME =/usr/lib/j2sdk1.5-sun
JRE_HOME =/usr/lib/j2sdk1.5-sun/jre
CLASSPATH =.:/usr/lib/j2sdk1.5-sun/lib/tools. jar:/usr/lib/j2sdk1.5-sun/lib/dt. jar
Export PATH
Export JRE_HOME
Export JAVA_HOME
Export CLASSPATH



6. Test
Set the current default java interpreter update-alternatives -- config java



The following figure is displayed after execution:

There are 4 alternatives which provide 'java '.
Selection Alternative

-----------------------------------------------

1/usr/bin/gij-wrapper-4.1

* + 2/usr/lib/jvm/java-gcj/jre/bin/java

3/usr/lib/jvm/java-1.5.0-sun/jre/bin/java

Press enter to keep the default
  • , Or type selection number: 3



    Enter the number before the row containing "sun. As shown above, enter 3 and press enter to confirm.

    For a simple test, you only need to execute the following command:

    $ Java-version


    You should see some information about the java version similar to the following:


    Java version "1.5.0 _ 06"
    Java (TM) 2 Runtime Environment, Standard Edition (build 1.5.0 _ 06-b05)
    Java HotSpot (TM) Client VM (build 1.5.0 _ 06-b05, mixed mode, sharing)



    A little effort-consuming testing
    Create a simple java program (Hello. java)


    Public class Hello {

    Public Hello (){
    }

    Public static void main (String [] args ){
    System. out. println ("Hello World! ");
    }

    }


    Then


    $ Javac Hello. java


    Check that the current directory will generate a file named Hello. class, and then run


    $ Java Hello
    Hello World!


    OK. The test is successful!

    7. Install the plug-in
    For the Java environment installed in this method, the location of the browser plug-in file should be:


    $ JAVA_HOME/jre/plugin/arch/ns7/libjavaplugin_oji.so


    For example:/usr/lib/j2sdk1.5-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so
    Take firefox (> 1.0) as an example:


    # Cd/usr/lib/mozilla-firefox/plugins
    # Ln-s \
    /Usr/lib/j2sdk1.5-sun/jre/plugin/i386/ns7/libjavaplugin_oji.so


    Or In Debian mode:


    # Update-alternatives -- verbose -- install \
    /Usr/lib/mozilla-firefox/plugins/libjavaplugin. so \
    Firefox-javaplugin.so \
    $ JAVA_HOME/jre/plugin/i386/ns7-gcc29/libjavaplugin_oji.so 500



    Then, restart the browser, browse the test page: http://serios.net/content/applets/viewinfoawt.php

    8. Uninstall
    Uninstall the software package:


    # Apt-get remove -- purge sun-j2sdk1.5


    Uninstall the plug-in and directly Delete the symbolic link:


    # Rm/usr/lib/mozilla-firefox/plugins/libjavaplugin_oji.so


    If you use the update-alternatives command to install the plug-in, you can run the following command to delete it:


    # Update-alternatives -- remove firefox-javaplugin.so \
    $ JAVA_HOME/jre/plugin/i386/ns7/libjavaplugin_oji.so


    9. Culture
    Install Chinese fonts:
    Create the fallback directory under the $ JAVA_HOME/jre/lib/fonts/directory.
    Copy the Chinese font (for example, simsun. ttf) to this directory.
  • 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.