JDK installation in Linux, environment variable settings in different shell environments for different users

Source: Internet
Author: User

 

Install JDK in Linux

Download the original JDK version of Sun: http://java.sun.com/products/archive/. you can download any JDK of sun. I used to find jdk1.4.2 _ 08 for a long time and I couldn't find it. I accidentally found this portal useful, so I added it to my favorites. After Oracle acquired sun, the address became: http://www.oracle.com/technetwork/java/archive-139210.html.

Download JDK (jdk-1_5_0_22-linux-i586.rpm) from the Internet first)

I. Standard installation

Download the package and put it in the/home directory. Of course it will be done elsewhere.

LStep 1

Go to the installation directory

# Cd/home

# Cp jdk-1_5_0_22-linux-i586.rpm/usr/local

# Cd/usr/local

Add executable permissions to all users

# Chmod + x jdk-1_5_0_22-linux-i586.rpm.bin

#./Jdk-1_5_0_22-linux-i586.rpm.bin

The file jdk-1_5_0_22-linux-i586.rpm is generated, and executable permissions are also added to all users

# Chmod + x jdk-1_5_0_22-linux-i586.rpm

Installer

# Rpm-IVH jdk-1_5_0_22-linux-i586.rpm

If the installation protocol is displayed, simply accept it.

Install JDK in Linux Step 2. Set environment variables.
1. Set Environment Variables
# Vi/etc/profile

Add at the end

# Set Java environment

Java_home =/usr/Java/jdk-1_5_0_22

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:
2. Set environment variables used by all users
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_22

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

Install JDK in Linux Step 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!

2. Install Multiple JDK versions

Installation Method:

If a Linux machine has multiple JDK versions. In addition, more than two applications are combined and different JDK versions are used. In this way, you need to set different environment variables for individual users.
And the user's shell is different. The JDK environment variables are different. In fact, install JDK in USR and set the environment variable to use it.

 

Extract Linux JDK executable files

Jdk-1_5_0_22-linux-i586.bin Decompression

Tar a package jdk-1_5_0_22.zip.

Put it in the USR directory and decompress it.

Set normal user environment variables

View shell usage

PS

Cshell

Bshell

Bshell user environment

1. Switch between common users
Su-Portal
2. Set the user's Java environment variables
Vi. bash_profile

Java_home =/usr/Java/jdk-1_5_0_22

Classpath =.: $ java_home/lib/tools. Jar

Path = $ java_home/bin: $ path

Export java_home classpath path
# Lang = zh_cn.gbk
# Export Lang
Note: The # character is used to set the user's Chinese encoding. Comment as needed
3. compile environment variables
.. Bash_profile
4. Check whether the environment variables take effect
> Echo $ java_home

> Echo $ classpath

> Echo $ path
> JAVA-version

C shell user environment
1. Switch between common users
Su-Portal
2. Set the user's Java environment variables
Vi. cshrc

# @ (#) Cshrc 1.11 89/11/29 SmI
Umask 022
Setenv java_home/usr/jdk1.5.22
Setenv path.:/usr/jdk1.5.22/bin
Setenv classpath/usr/jdk1.5.22/lib/tools. Jar
Setenv jre_home/usr/jdk1.5.22/JRE
# Setenv Lang zh_cn.gbk
Note: The # character is used to set the user's Chinese encoding. Comment as needed
3. compile environment variables
Source. cshrc
4. Check whether the environment variables take effect
> Echo $ java_home

> Echo $ classpath

> Echo $ path
> JAVA-version

The above is the accumulation of Application Deployment and integration, and the layout is not good. Let's take a look.

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.