java jdk在Linux下安装与环境变量的配置
by:授客 QQ:1033553122
linux环境:CentOS-6.0-x86_64-bin-DVD1.iso
[root@localhost software]# ls
jdk-6u13-linux-i586.bin jdk-6u13-linux-i586.zip
步骤1.创建并java安装目录
[root@localhost software]# mkdir -p /usr/local/java
[root@localhost software]# mv jdk-6u13-linux-i586.bin /usr/local/java
[root@localhost software]# cd /usr/local/java/
[root@localhost java]# ls
jdk-6u13-linux-i586.bin
步骤2.更改安装程序权限
[root@localhost java]# chmod 777 jdk-6u13-linux-i586.bin
步骤3.运行程序
[root@localhost java]# ./jdk-6u13-linux-i586.bin
...
./jdk-6u13-linux-i586.bin: ./install.sfx.5278: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
Failed to extract the files. Please refer to the Troubleshooting section of
the Installation Instructions on the download page for more information.
#如上,报错,解决方法:安装64位的jdk
[root@localhost java]# chmod 777 jdk-6u4-linux-x64-rpm.bin
[root@localhost java]# ./jdk-6u4-linux-x64-rpm.bin
[root@localhost java]# ls
jdk-6u4-linux-amd64.rpm sun-javadb-common-10.3.1-4.1.i386.rpm sun-javadb-docs-10.3.1-4.1.i386.rpm
jdk-6u4-linux-x64-rpm.bin sun-javadb-core-10.3.1-4.1.i386.rpm sun-javadb-javadoc-10.3.1-4.1.i386.rpm
sun-javadb-client-10.3.1-4.1.i386.rpm sun-javadb-demo-10.3.1-4.1.i386.rpm
[root@localhost java]# rpm -ivh jdk-6u4-linux-amd64.rpm
Preparing... ########################################### [100%]
package jdk-2000:1.6.0_04-fcs.x86_64 is already installed
步骤4.设置环境变量
[root@localhost java]# find / -name dt.jar
/usr/java/jdk1.6.0_04/lib/dt.jar
#修改权限,否则会提示类似以下的错误
#-bash: /usr/java/jdk1.6.0_04/lib/dt.jar: Permission denied
[root@localhost lib]# chmod 777 /usr/java/jdk1.6.0_04/lib/dt.jar
[root@localhost lib]# chmod 777 /usr/java/jdk1.6.0_04/lib/tools.jar
[root@localhost java]# export JAVA_HOME=/usr/java/jdk1.6.0_04
[root@localhost java]# export JRE_HOME=/usr/java/jdk1.6.0_04/jre
[root@localhost lib]# export CLASSPATH=.:$JAVA_HOME/lib/dt.jar
:$JAVA_HOME/lib/tools.jar
[root@localhost lib]# export PATH=$JAVA_HOME/bin:$JAVA_hOME/jre/bin:$PATH
[root@localhost lib]# source /etc/profile #让配置文件立即生效
注意,以上仅是临时起用作的,要永久生效,必须写入配置文件
# vi /etc/profile
……
[root@localhost lib]# source /etc/profile #让配置文件立即生效