Linux:Ubuntu 14.04 Server 离线安装Jjava8(及在线安装)
- (离线安装)首先,通过winscp上传本地下载好的jdk-8u102-linux-x64.gz
- (离线安装)将jdk-8u102-linux-x64.gz解压到到/usr/lib/jvm下,并把文件夹名重命名为java-8-oracle:
hadoop@master:/usr/lib$ mkdir jvm
hadoop@master:/usr/lib$ ls
。。。jvm 。。。
hadoop@master:/usr/lib$ cd /home/hadoop
hadoop@master:~$ sudo cp -r jdk-8u102-linux-x64.gz /usr/lib
hadoop@master:~$ cd /usr/lib
hadoop@master:/usr/lib$ ls
... jdk-8u102-linux-x64.gz ...
hadoop@master:/usr/lib$ sudo tar -zxvf jdk-8u102-linux-x64.gz -C jvm/
hadoop@master:/usr/lib$ cd jvm
hadoop@master:/usr/lib/jvm$ ls
jdk1.8.0_102
hadoop@master:/usr/lib$ cd ..
hadoop@master:/usr/lib$ sudo rm jdk-8u102-linux-x64.gz
hadoop@master:/usr/lib$ cd jvm
hadoop@master:/usr/lib/jvm$ mv jdk1.8.0_102/ java-8-oracle
mv: cannot move ‘jdk1.8.0_102/’ to ‘java-8-oracle’: Permission denied
hadoop@master:/usr/lib/jvm$ sudo mv jdk1.8.0_102/ java-8-oracle/
hadoop@master:/usr/lib/jvm$ ls
java-8-oracle
hadoop@master:/usr/lib/jvm$
- (离线安装)设置环境变量
hadoop@master:~$ 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我测试不行,于是重启了服务器,发现可以。
hadoop@master:~$ 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)
- 在线安装方法一:
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保存并退出*/
-
在线安装方法二:
wget http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/jdk-8u161-linux-x64.tar.gz?AuthParam=1522506006_6fffc05b7c064c1b0023fd4a4f8612b8 mv jdk-8u161-linux-x64.tar.gz\?AuthParam\=1522506006_6fffc05b7c064c1b0023fd4a4f8612b8 jdk-8u161-linux-x64.tar.gz mkdir /usr/local/java/ tar -zxvf jdk-8u161-linux-x64.tar.gz -C /usr/local/java/ vi /etc/profile 在/etc/profile 末尾添加以下记录: # config java class path export JAVA_HOME=/usr/local/java/jdk1.8.0_161 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH source /etc/profile 测试 java -version [root@localhost jdk1.8.0_161]# java -version java version "1.8.0_161" Java(TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode) [root@localhost jdk1.8.0_161]# vi /etc/profile
针对方法二,也可以参考:https://blog.csdn.net/fuyuwei2015/article/details/73195936
基础才是编程人员应该深入研究的问题,比如:
1)List/Set/Map内部组成原理|区别
2)mysql索引存储结构&如何调优/b-tree特点、计算复杂度及影响复杂度的因素。。。
3)JVM运行组成与原理及调优
4)Java类加载器运行原理
5)Java中GC过程原理|使用的回收算法原理
6)Redis中hash一致性实现及与hash其他区别
7)Java多线程、线程池开发、管理Lock与Synchroined区别
8)Spring IOC/AOP 原理;加载过程的。。。
【+加关注】。