Linux:Ubuntu 14.04 Server 离线安装Jjava8(及在线安装)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux:Ubuntu 14.04 Server 离线安装Jjava8(及在线安装)相关的知识,希望对你有一定的参考价值。
- (离线安装)首先,通过winscp上传本地下载好的jdk-8u102-linux-x64.gz
- (离线安装)将jdk-8u102-linux-x64.gz解压到到/usr/lib/jvm下,并把文件夹名重命名为java-8-oracle:
[email protected]:/usr/lib$ mkdir jvm
[email protected]:/usr/lib$ ls
。。。jvm 。。。
[email protected]:/usr/lib$ cd /home/hadoop
[email protected]:~$ sudo cp -r jdk-8u102-linux-x64.gz /usr/lib
[email protected]:~$ cd /usr/lib
[email protected]:/usr/lib$ ls
... jdk-8u102-linux-x64.gz ...
[email protected]:/usr/lib$ sudo tar -zxvf jdk-8u102-linux-x64.gz -C jvm/
[email protected]:/usr/lib$ cd jvm
[email protected]:/usr/lib/jvm$ ls
jdk1.8.0_102
[email protected]:/usr/lib$ cd ..
[email protected]:/usr/lib$ sudo rm jdk-8u102-linux-x64.gz
[email protected]:/usr/lib$ cd jvm
[email protected]:/usr/lib/jvm$ mv jdk1.8.0_102/ java-8-oracle
mv: cannot move ‘jdk1.8.0_102/’ to ‘java-8-oracle’: Permission denied
[email protected]:/usr/lib/jvm$ sudo mv jdk1.8.0_102/ java-8-oracle/
[email protected]:/usr/lib/jvm$ ls
java-8-oracle
[email protected]:/usr/lib/jvm$
- (离线安装)设置环境变量
[email protected]:~$ sudo vim /etc/profile
在profile文件末尾追加一下行:
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export JRE_HOME_/usr/lib/jvm/java-8-oracle
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=$CLASS_PATH::$JAVA_HOME/lib:$JAVA_HOME/jre/lib
(esc,:wq!保存)
hadoop@master:~$ sudo update-alternatives --install /usr/bin/Java java /usr/lib/jvm/java-8-oracle/bin/java 300
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/java to provide /usr/bin/Java (java) in auto mode
hadoop@master:~$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-8-oracle/bin/javac 300
update-alternatives: using /usr/lib/jvm/java-8-oracle/bin/javac to provide /usr/bin/javac (javac) in auto mode
hadoop@master:~$ sudo update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/Java): /usr/lib/jvm/java-8-oracle/bin/java
Nothing to configure.
hadoop@master:~$ sudo update-alternatives --config javac
There is only one alternative in link group javac (providing /usr/bin/javac): /usr/lib/jvm/java-8-oracle/bin/javac
Nothing to configure.
- (离线安装)测试是否安装好
java -version我测试不行,于是重启了服务器,发现可以。
[email protected]:~$ java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
- (在线安装)安装java8
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install Oracle-java8-Installer
如果在执行 sudo add-apt-repository ppa:webupd8team/java 命令时,提示“Cannot add PPA:xxx”,一般是因为CA证书损坏。执行如下命令修复:
sudo apt-get install --reinstall ca-certificates
设置JAVA_HOME环境变量:
$ vim /etc/profile
在文件最前面添加如下单独一行(注意 = 号前后不能有空格),并保存:
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
/*按esc 输入 :wq保存并退出*/
参考:http://blog.csdn.net/sddi1989/article/details/7995042
以上是关于Linux:Ubuntu 14.04 Server 离线安装Jjava8(及在线安装)的主要内容,如果未能解决你的问题,请参考以下文章
在 Linux(Ubuntu 13.10 和 14.04)下运行没有 QtCoreApplication/QCoreApplication 的 Qt C++ 代码
Linux:Ubuntu14.04离线安装scala(在线安装)