Install JDK in Ubuntu and configure the Java environment

Source: Internet
Author: User

1. Download the Sun JDK file from the Oracle official website. I downloaded the jdk-6u22-linux-i586.bin.

2. Permission setting and Installation
I want to install JDK under the program directory for myself, copy the jdk-6u22-linux-i586.bin to/home/xuwei/Program
Run the CD command on the terminal to go to the/home/xuwei/Program/directory,
Then execute the command
Sudo chmod + x jdk-6u22-linux-i586.bin // Set permissions
Sudo./jdk-6u22-linux-i586.bin // execution File

PS: 2011-9-30

After reading other people installing JDK on the Internet, they all choose the/usr/Java directory. If you use the apt command to install JDK, install it in the/usr/lib/JVM/directory. Now I will run a manual command to copy JDK. bn to the/usr/lib/JVM directory, and install it through the above operations.

3. Configure Environment Variables
# Sudo gedit/etc/profile
Add at the end
# Set Java environment
Export java_home =/home/xuwei/Program/jdk1.6.0 _ 22
Export Path = $ java_home/bin: $ path
Export classpath =.: $ java_home/lib/tools. jar: $ java_home/lib/dt. jar: $ classpath
Save and exit.

4. log out and log on again (important. If this step is not completed, Echo cannot display the correct path and empty lines)
Run the echo command on the terminal to check the environment variable settings.
# Echo $ java_home
# Echo $ classpath
# Echo $ path

5. Check whether JDK is successfully installed.
# Java-version
Display:
Java version "1.6.0 _ 22"
Java (TM) se Runtime Environment (build 1.6.0 _ 22-b04)
Java hotspot (TM) server VM (build 17.1-b03, mixed mode)
If you see the JVM version and related information, the installation is successful!

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.