Ubuntu 下JDK的安装与环境配置
在 Ubuntu 64 12.4 位操作系统下安装jdk-6u45-linux-x64.bin文件一、复制JDK到安装目录1.假设JDK安装文件放在桌面,我们要安装的目录为:/usr/local/java。我们先在 /usr/local/目录下创建java文件夹:aosp444@aosp444-virtual-machine:/usr/local$ sudo mkdir java[sudo]
一、JDK bin文件安装
在 Ubuntu 64 12.4 位操作系统下安装jdk-6u45-linux-x64.bin文件
一、复制JDK到安装目录
1.假设JDK安装文件放在桌面,我们要安装的目录为:/usr/local/java。
我们先在 /usr/local/目录下创建java文件夹:
aosp444@aosp444-virtual-machine:/usr/local$ sudo mkdir java
[sudo] password for aosp444:
aosp444@aosp444-virtual-machine:/usr/local$ ll
total 44
drwxr-xr-x 11 root root 4096 May 30 20:35 ./
drwxr-xr-x 10 root root 4096 Aug 7 2014 ../
drwxr-xr-x 2 root root 4096 Aug 7 2014 bin/
drwxr-xr-x 2 root root 4096 Aug 7 2014 etc/
drwxr-xr-x 2 root root 4096 Aug 7 2014 games/
drwxr-xr-x 2 root root 4096 Aug 7 2014 include/
drwxr-xr-x 2 root root 4096 May 30 20:35 java/
drwxr-xr-x 3 root root 4096 Aug 7 2014 lib/
lrwxrwxrwx 1 root root 9 May 30 19:38 man -> share/man/
drwxr-xr-x 2 root root 4096 Aug 7 2014 sbin/
drwxr-xr-x 7 root root 4096 Aug 8 2014 share/
drwxr-xr-x 2 root root 4096 Aug 7 2014 src/
aosp444@aosp444-virtual-machine:/usr/local$
2.切换到桌面,复制安卓文件到安装目录:
aosp444@aosp444-virtual-machine:~/Desktop$ sudo cp jdk-6u45-linux-x64.bin /usr/local/java
aosp444@aosp444-virtual-machine:~/Desktop$
二、安装JDK
1.切换到JDK安装目录下,修改 安装文件权限:
aosp444@aosp444-virtual-machine:/usr/local/java$ sudo chmod 777 jdk-6u45-linux-x64.bin
aosp444@aosp444-virtual-machine:/usr/local/java$
2.运行安装文件
aosp444@aosp444-virtual-machine:/usr/local/java$ sudo ./jdk-6u45-linux-x64.bin
3.安装成功后,java文件夹下多了一个文件夹:
aosp444@aosp444-virtual-machine:/usr/local/java$ ll
total 70412
drwxr-xr-x 3 root root 4096 May 30 20:46 ./
drwxr-xr-x 11 root root 4096 May 30 20:35 ../
drwxr-xr-x 8 root root 4096 Mar 27 2013 jdk1.6.0_45/
-rwxrwxrwx 1 root root 72087592 May 30 20:39 jdk-6u45-linux-x64.bin*
aosp444@aosp444-virtual-machine:/usr/local/java$
三、配置环境变量
1.打开/ect/profile 文件
sudo gedit /etc/profile
2.添加下面的环境变量,要根据安装目录修改,并保存。
# Java Environment
export JAVA_HOME=/usr/local/java/jdk1.6.0_45
export JRE_HOME=/usr/local/java/jdk1.6.0_45/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$JAVA_HOME:$PATH
3.重启后使其生效并进行验证
也可使用下面的命令不重启使其生效,不过只针对当前域有效。
aosp444@aosp444-virtual-machine:/usr/local/java$ source /etc/profile
aosp444@aosp444-virtual-machine:/usr/local/java$
输入java -version 进行验证,成功后如下:
aosp444@aosp444-virtual-machine:/usr/local/java$ 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)
aosp444@aosp444-virtual-machine:/usr/local/java$
二、JDK tar.gz文件安装
在 Ubuntu 64 16.4 位操作系统下安装文件jdk-7u55-linux-x64.tar.gz 文件
一、复制JDK到安装目录
1.假设JDK安装文件放在桌面,我们要安装的目录为:/usr/local/java。
我们先在 /usr/local/目录下创建java文件夹:
android642@android642-vm:/usr/local$ sudo mkdir java
[sudo] password for android642:
android642@android642-vm:/usr/local$ ll
total 44
drwxr-xr-x 11 root root 4096 8月 17 11:29 ./
drwxr-xr-x 11 root root 4096 8月 1 19:24 ../
drwxr-xr-x 2 root root 4096 8月 1 19:17 bin/
drwxr-xr-x 2 root root 4096 8月 1 19:17 etc/
drwxr-xr-x 2 root root 4096 8月 1 19:17 games/
drwxr-xr-x 2 root root 4096 8月 1 19:17 include/
drwxr-xr-x 2 root root 4096 8月 17 11:29 java/
drwxr-xr-x 4 root root 4096 8月 1 19:20 lib/
lrwxrwxrwx 1 root root 9 8月 16 17:59 man -> share/man/
drwxr-xr-x 2 root root 4096 8月 1 19:17 sbin/
drwxr-xr-x 8 root root 4096 8月 1 19:27 share/
drwxr-xr-x 2 root root 4096 8月 1 19:17 src/
android642@android642-vm:/usr/local$ cd java
android642@android642-vm:/usr/local/java$
2.切换到桌面,复制安卓文件到安装目录:
android642@android642-vm:~/Desktop$ sudo cp jdk-7u80-linux-x64.tar.gz /usr/local/java
android642@android642-vm:~/Desktop$
二、安装JDK
1.解压jdk-7u80-linux-x64.tar.gz
切换到/usr/loal/java
目录,将jdk-7u80-linux-x64.tar.gz
文件解压到当前目录
android642@android642-vm:/usr/local/java$ sudo tar -zxvf jdk-7u80-linux-x64.tar.gz
2.解压成功后,java文件夹下多了一个文件夹jdk1.7.0_80
:
android642@android642-vm:/usr/local/java$ ll
total 149952
drwxr-xr-x 3 root root 4096 8月 17 11:39 ./
drwxr-xr-x 11 root root 4096 8月 17 11:29 ../
drwxr-xr-x 8 uucp 143 4096 4月 11 2015 jdk1.7.0_80/
-rwxr--r-- 1 root root 153530841 8月 17 11:33 jdk-7u80-linux-x64.tar.gz*
android642@android642-vm:/usr/local/java$
三、配置环境变量
1.打开/ect/profile 文件
sudo gedit /etc/profile
2.添加下面的环境变量,要根据安装目录修改,并保存。
# Java Environment
export JAVA_HOME=/usr/local/java/jdk1.7.0_80
export JRE_HOME=/usr/local/java/jdk1.7.0_80/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$JAVA_HOME:$PATH
3.重启后使其生效并进行验证
也可使用下面的命令不重启使其生效,不过只针对当前域有效。
android642@android642-vm:/usr/local/java$ source /etc/profile
输入java -version 进行验证,成功后如下:
android642@android642-vm:/usr/local/java$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
android642@android642-vm:/usr/local/java$
更多推荐
所有评论(0)