🔖 JDK 安装脚本和文档
parent
7ccbb190af
commit
eb615fca53
15
README.md
15
README.md
|
@ -32,6 +32,17 @@
|
|||
* [git 快速指南](docs/git/git-quickstart.md)
|
||||
* [git-flow 工作流](docs/git/git-flow.md)
|
||||
|
||||
## 工具
|
||||
## 部署
|
||||
|
||||
> 这里总结了各种软件的安装、配置。并提供基本安装、运行的脚本。
|
||||
>
|
||||
> [环境部署工具](codes/deploy/README.md) :适合开发、运维人员,在 [CentOS](https://www.centos.org/) 机器上安装常用命令工具或开发软件。
|
||||
|
||||
### 常见软件安装配置详述
|
||||
|
||||
> CODES:安装配置脚本,按照说明即可安装使用。
|
||||
>
|
||||
> DOCS: 安装配置文档,说明安装的方法以及一些注意事项。
|
||||
|
||||
* JDK 安装和配置:| [CODES](codes/deploy/tool/jdk) | [DOCS](docs/deploy/tool/jdk/install-jdk.md) |
|
||||
|
||||
[环境部署工具](codes/deploy/README.md) :适合开发、运维人员,在 [CentOS](https://www.centos.org/) 机器上安装常用命令工具或开发软件。
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# 安装 JDK
|
||||
|
||||
## linux 安装JDK通用脚本
|
||||
|
||||
使用方法:
|
||||
|
||||
```sh
|
||||
wget --no-check-certificate --no-cookies https://raw.githubusercontent.com/dunwu/linux/master/codes/deploy/tool/jdk/install-jdk8.sh
|
||||
chmod -R 777 install-jdk8.sh
|
||||
./install-jdk8.sh
|
||||
```
|
||||
|
||||
脚本会下载解压 jdk8 到 `/opt/software/java` 路径下。
|
||||
|
||||
## Centos 安装JDK脚本
|
||||
|
||||
使用方法:
|
||||
|
||||
```sh
|
||||
wget --no-check-certificate --no-cookies https://raw.githubusercontent.com/dunwu/linux/master/codes/deploy/tool/jdk/install-jdk8-by-yum.sh
|
||||
chmod -R 777 install-jdk8-by-yum.sh
|
||||
./install-jdk8-by-yum.sh
|
||||
```
|
||||
脚本会下载解压 jdk8 到 `/usr/lib/jvm/java` 路径下。
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
###################################################################################
|
||||
# 安装 JDK8 脚本
|
||||
# 仅适用于所有 Centos 发行版本
|
||||
# JDK 会被安装到 /usr/lib/jvm/java 路径。
|
||||
# Author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
echo -e "\n>>>>>>>>> install jdk8"
|
||||
|
||||
yum -y install java-1.8.0-openjdk-devel-debug.x86_64
|
||||
|
||||
cat >> /etc/profile << EOF
|
||||
|
||||
export JAVA_HOME=/usr/lib/jvm/java
|
||||
export PATH=\$JAVA_HOME/bin:\$PATH
|
||||
export CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
|
||||
EOF
|
||||
source /etc/profile
|
|
@ -1,15 +1,24 @@
|
|||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
###################################################################################
|
||||
# 安装 JDK8 脚本
|
||||
# 适用于所有 linux 发行版本。
|
||||
# JDK 会被安装到 /opt/software/java/jdk1.8.0_162 路径。
|
||||
# Author: Zhang Peng
|
||||
###################################################################################
|
||||
|
||||
echo -e "\n>>>>>>>>> install jdk8"
|
||||
|
||||
yum -y install java-1.8.0-openjdk-devel-debug.x86_64
|
||||
mkdir -p /opt/software/java
|
||||
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" -O /opt/software/java/jdk-8u162-linux-x64.tar.gz http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-x64.tar.gz
|
||||
|
||||
cd /opt/software/java
|
||||
tar -zxvf jdk-8u162-linux-x64.tar.gz
|
||||
|
||||
cat >> /etc/profile << EOF
|
||||
JAVA_HOME=/usr/lib/jvm/java
|
||||
PATH=${JAVA_HOME}/bin:\$PATH
|
||||
CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
|
||||
export JAVA_HOME
|
||||
export PATH
|
||||
export CLASSPATH
|
||||
|
||||
export JAVA_HOME=/opt/software/java/jdk1.8.0_162
|
||||
export PATH=\$JAVA_HOME/bin:\$PATH
|
||||
export CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
|
||||
EOF
|
||||
source /etc/profile
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
# JDK 安装
|
||||
|
||||
## CentOS 下安装
|
||||
|
||||
安装方法有两种:压缩包安装和 yum 安装
|
||||
|
||||
### 压缩包安装
|
||||
|
||||
安装步骤如下:
|
||||
|
||||
(1)下载
|
||||
|
||||
进入官网下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html ,选择合适的版本下载。
|
||||
|
||||
我选择的是最新 JDK8 版本:http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-x64.tar.gz
|
||||
|
||||
(2)解压到本地
|
||||
|
||||
我个人喜欢存放在:`/opt/software/java`
|
||||
|
||||
(3)设置环境变量
|
||||
|
||||
输入 `vi /etc/profile` ,添加环境变量如下:
|
||||
|
||||
```
|
||||
# JDK 的根路径
|
||||
export JAVA_HOME=/opt/software/java/jdk1.8.0_162
|
||||
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
|
||||
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
|
||||
```
|
||||
|
||||
执行 `source /etc/profile` ,立即生效
|
||||
|
||||
(4)检验是否安装成功,执行 `java -version` 命令
|
||||
|
||||
### yum 安装
|
||||
|
||||
安装步骤如下:
|
||||
|
||||
(1)查看可以安装的JDK版本
|
||||
|
||||
执行下面命令查看当前 linux 发型版本可以下载安装的 JDK 版本。
|
||||
|
||||
```
|
||||
yum search java | grep openjdk
|
||||
```
|
||||
|
||||
(2)选择一个合适的版本安装
|
||||
|
||||
```
|
||||
yum -y install java-1.8.0-openjdk-devel-debug.x86_64
|
||||
```
|
||||
|
||||
安装成功后,默认安装路径在 `/usr/lib/jvm/java`
|
||||
|
||||
(3)设置环境变量,同压缩包安装。
|
||||
|
||||
(4)检验是否安装成功,执行 `java -version` 命令
|
||||
|
||||
## 脚本
|
||||
|
||||
以上两种安装方式,我都写了脚本去执行:
|
||||
|
||||
| [安装脚本](https://github.com/dunwu/linux/tree/master/codes/deploy/tool/jdk) |
|
Loading…
Reference in New Issue