1:将下载的 jdk-6u29-linux-x64.bin 放置在创建的 xiazhaoxian\java 文件夹中
2:进入 JAVA 文件夹
cd java
3:安装 运行指令 sudo sh jdk-6u29-linux-x64.bin
4:配置环境变量
sudo gedit /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"之后添加如下代码:
- # set java environment
- export JAVA_HOME=/home/xiazhaoxian/java/jdk1.6.0_29
- export JRE_HOME=/home/xiazhaoxian/java/jdk1.6.0_29/jre
- export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
sudo gedit /etc/profile
在umask 022之前添加以下语句:
- # set java environment
- export JAVA_HOME=/home/xiezhaoxian/java/jdk1.6.0_29
- export JRE_HOME=$JAVA_HOME/jre
- export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
- export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
5:如何默认java :
进入位置--》主文件夹 找到 .bashrc文件(由于这个文件默认是隐藏的所以按下CTRL+H键显示)在文件最后加上
export JAVA_HOME=/home/xiezhaoxian/java/jdk1.6.0_29
PATH=.:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
6:检查是否安装成功:
- lq@lq:~$ echo $JAVA_HOME
- /home/lq/java/jdk1.6.0_29
- lq@lq:~$ echo $CLASSPATH
- .:/home/lq/java/jdk1.6.0_29/lib:/home/lq/java/jdk1.6.0_29/jre/lib:
- lq@lq:~$ echo $PATH
- /home/lq/java/jdk1.6.0_29/bin:/home/lq/java/jdk1.6.0_29/jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
- lq@lq:~$ java -version
- java version "1.6.0_25"
- Java(TM) SE Runtime Environment (build 1.6.0_29-b06)
- Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)