Manually configure JDK under ubuntu10.0.4

Source: Internet
Author: User

JDK can be installed in multiple ways in Ubuntu, for example, search for "sun-java6-jre" and "sun-java6-jdk" and tag the installation with adept/new software manager, and install with the apt-GET command (SUDO apt-Get install sun-java6-jre, sudo apt- get install sun-java6-jdk), You can also download the JDK installation file from the Java official website for manual installation (I downloaded the file is: jdk-6u20-linux-i586.bin), which is exactly a kind of installation method described in this article.

 

By default, the installation files downloaded from the official website (such as: jdk-6u20-linux-i586.bin) are not permitted to execute, You can query the relevant information through the $ LS-l command, so the first step is to give the Installation File executable permissions, can be achieved through the command $ sudo chmod U + x/usr/lib/Java/jdk-6u20-linux-i586.bin.

 

After successfully modifying the permissions of the Installation File, run the command $ CD/usr/lib/Java/to enter the directory where the installation file is located, and then run the command $. /jdk-6u20-linux-i586.bin screen will show JDK installation information, and then press enter until the screen display requires the input YES/NO, then enter y and press enter, the current directory contains an additional JDK 1.6.0 _ 20 Directory, which means JDK has been installed successfully.

 

After successfully installing the JDK, We will configure the JDK and use the command $ sudo gedit/etc/environment to modify the environment file and add the followingCode:

 

Java code
    1. Path ="/Usr/lib/Java/jdk1.6.0 _ 20/bin"
    2. Classpath ="/Usr/lib/Java/jdk1.6.0 _ 20/lib"
    3. Java_home ="/Usr/lib/Java/jdk1.6.0 _ 20"
 
Path = "/usr/lib/Java/jdk1.6.0 _ 20/bin" classpath = "/usr/lib/Java/jdk1.6.0 _ 20/lib" java_home = "/usr/lib/ java/jdk1.6.0 _ 20"

If path already exists, use the colon as the interval to add the bin directory address of JDK, so that the Java environment variable is configured successfully, however, the JDK used by default may not have been installed just now, Because ubuntu may also have a default JDK, such as openjdk; therefore, in order to make the JDK installed by default, you also need to execute the following command:

 

Java code
    1. $ sudo Update-alternatives -- install/usr/bin/Java/usr/lib/Java/jdk1. 6 . 0_20/bin/Java 300
    2. $ sudo Update-alternatives -- install/usr/bin/javac/usr/lib/Java/jdk1. 6 . 0_20/bin/javac 300
    3. $ sudo Update-alternatives -- config Java
$ Sudo Update-alternatives -- install/usr/bin/Java/usr/lib/Java/jdk1.6.0 _ 20/bin/Java 300 $ sudo Update-alternatives -- install/usr/bin /javac/usr/lib/Java/jdk1.6.0 _ 20/bin/javac 300 $ sudo Update-alternatives -- config Java

After the command is successfully executed, the JDK we installed is the default one. You can run $ Java-version to view the JDK information, for example:

Java code
    1. Java version"1.6.0 _ 20"
    2. Java (TM) se Runtime Environment (build1.6. 0_20-b02)
    3. Java hotspot (TM) server VM (build16.3-B01, mixed mode)

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.