Install JDK in Linux and set the environment

Source: Internet
Author: User
Tags echo command

Method 1:

1. log on to the system as root

2. Go to java.sun.com to download the rpm for jdk1.5.0 for Linux. It should be a jdk-1_5_x-rc-linux-i586-rpm.bin File

3. Run the CHMOD + x jdk-1_5_x-rc-linux-i586-rpm.bin command to give it executable permissions

4. Install with rpm-IVH jdk-1_5_x-rc-linux-i586-rpm.bin

5. JDK is installed in the/usr/Java/directory.

6. Set environment variables (write to/etc/profile)

Export java_home =/usr/Java/jdk1.5
Export Path = $ path: $ java_home/bin: $ java_home/JRE/bin
Export classpath =.:/usr/Java/jdk1.5/lib:/usr/Java/jdk1.5/JRE/lib: $ classpath

Okay typed Java-version. If the JDK version information is displayed, it indicates that the JDK version is successful.

For the convenience of development, I made another Eclipse IDE, so that I can develop Java in Linux later.

Eclipse installation is much simpler. After downloading (a zip package), you can directly unzip it to the directory you want. I will decompress it to/OPT.

Method 2:

1. First download JDK (jdk-1_5_0_02-linux-i586.rpm) from the Internet, recommend Sun's official website www.sun.com, download and put it in the/home directory, of course, other places also do.
Go to the installation directory
# Cd/home
# Cp jdk-1_5_0_02-linux-i586.rpm/usr/local
# Cd/usr/local
Add executable permissions to all users
# Chmod + x jdk-1_5_0_02-linux-i586.rpm.bin
#./Jdk-1_5_0_02-linux-i586.rpm.bin
The file jdk-1_5_0_02-linux-i586.rpm is generated, and executable permissions are also added to all users
# Chmod + x jdk-1_5_0_02-linux-i586.rpm
InstallProgram
# Rpm-IVH jdk-1_5_0_02-linux-i586.rpm
If the installation protocol is displayed, press <enter>.

2. Set environment variables.
# Vi/etc/profile
Add at the end
# Set Java environment
Java_home =/usr/Java/jdk-1_5_0_02
Classpath =.: $ java_home/lib. Tools. Jar
Path = $ java_home/bin: $ path
Export java_home classpath path
Save and exit.

To enable JDK to be used by all users, you can:
VI/etc/profile. d/Java. Sh
Enter the following content in the new java. Sh file:
# Set Java environment
Java_home =/usr/Java/jdk-1_5_0_02
Classpath =.: $ java_home/lib. Tools. Jar
Path = $ java_home/bin: $ path
Export java_home classpath path
Save and exit, and then assign the permission to Java. sh: chmod 755/etc/profile. d/Java. Sh

3. Use the echo command on the terminal to check the environment variable settings.
# Echo $ java_home
# Echo $ classpath
# Echo $ path

4. Check whether JDK is successfully installed.
# Java-version
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.