Linux下安装JDK
系统环境
[root@localhost ~]# file /sbin/init
/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@localhost ~]#
安装文件为 jdk-6u45-linux-x64.bin \\这是64位的环境
mkdir /usr/java \\创建Java目录,将jdk-6u45-linux-x64.bin拷贝到该目录下
执行 chmod 777 jdk-6u45-linux-x64.bin \\ 使其具有执行权限
执行 ll jdk-6u45-linux-x64.bin \\确认其是否具有+x权限
[root@localhost ~]# cd /usr/java/
[root@localhost java]# pwd
/usr/java
[root@localhost java]# ll jdk-6u45-linux-x64.bin
-rwxrwxrwx. 1 root root 72087592 Dec 7 09:48 jdk-6u45-linux-x64.bin
[root@localhost java]# ./jdk-6u45-linux-x64.bin \\安装在当前目录下
[root@localhost java]# ls
jdk1.6.0_45 jdk-6u45-linux-x64.bin \\ 会看到jdk1.6.0_45目录
[root@localhost java]#
编辑 vi /etc/profile 末尾添加路径变量如下
JAVA_HOME=/usr/java/jdk1.6.0_45 \\ /usr/java 这是指定安装路径
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib/:$CLASSPATH
export JAVA_HOME CLASSPATH PATH
然后 logout 重新登录
执行 java -version 会看到
[root@localhost ~]# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
[root@localhost ~]#
环境就创建好了
本文出自 “无视的流离” 博客,请务必保留此出处http://aiqhx.blog.51cto.com/5768342/1557601
原文地址:http://aiqhx.blog.51cto.com/5768342/1557601