Install JDK under Linux and configure environment variables

Source: Internet
Author: User

1. Query whether a JDK is installed by default
[[email protected]   bin]"1.6.0_22"Environment (1.10.  4) (rhel-1.41.  1.10.4.el6-x86_64)64-20.0-b11, mixed mode)         
2. Remove the default installation of OPENJDK
[[Email protected]Bin# Rpm-qa | grep jdkjava-1.6.0-openjdk-javadoc-1.6.0.0-1.41.1.10.4.el6.x86_64java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86_64java-1.6.0-openjdk-devel-1.6.0.0-1.41.1.10.4.el6.x86_64[[email protected]bin] # RPM-E--nodeps java-1.6.0-openjdk-javadoc-1.6.0.0-1.41.1.10.4.el6.x86_64[[email protected] bin]# rpm-e --nodeps Java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86_64[[email protected] bin]# rpm-e--nodeps Java-1.6.0-openjdk-devel-1.6.0.0-1.41.1.10.4.el6.x86_64[[email protected] bin]# Rpm-qa | grep jdk[[email Protected] bin]#         
3. Oracle website download

Go to the website by yourself

< span class= "comment" >< span class= "variable" >< span class= "constant" > < span class= "comment" >< span class= "variable" >jdk1.6.0_45- linux-x64.tar.gz

4. Installing the JDK
[Email protected] soft]# TAR-ZXVF< span class= "comment" >< span class= "variable" >< span class= "constant" > < span class= "comment" >< span class= "variable" >jdk1.6.0_45   -linux-x64.tar.gz[[Email protected] ~]# Mkdir/usr/java[[email protected] ~]# mv jdk1.6.0_45//usr/java/jdk1.6.0 _45    
5. Configuring the JDK environment variables

To configure/etc/profile, add the following configuration to the end of the file:

Java_home=/usr/java/jdk1.6.0_45classpath=.:$JAVA _home/lib.tools.jarpath=$JAVA _home/bin:$PATHexport Java_home CLASSPATH PATH  

To configure the. Bash_profile for a normal user, example with Crxj-app as an example, you can vi/home/crxj-app/.bash_profile, plus the following configuration:

Java_home=/usr/java/jdk1.6.0_45java_bin=/usr/java/jdk1.6.0_45/binclasspath=.:$JAVA _home/lib/tools.jar:  $JAVA _home/lib:$JAVA _home/binexport java_home java_bin classpathexport path=$PATH:$JAVA _home/bin 

Effective configuration environment

[Crxj-app@CRXJ-app-2 UAP]$ source/etc/profile   

Test your JDK Environment

#下列任意命令都可以检测JDK环境是否安装正确java-versionjavac-version$JAVA _home

Install JDK under Linux and configure environment variables

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.