Created
March 31, 2017 07:49
-
-
Save wenpeng/039627f9fd17e5054cafe361f2bed94a to your computer and use it in GitHub Desktop.
JDK 环境配置
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Author: yeho <lj2007331 AT gmail.com> | |
# BLOG: https://blog.linuxeye.com | |
# | |
# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+ | |
# | |
# Project home page: | |
# https://oneinstack.com | |
# https://github.com/lj2007331/oneinstack | |
JDK_PATH=/usr/local/java/jdk1.8.0_121 | |
[ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile | |
[ -z "`grep ^'export CLASSPATH=' /etc/profile`" ] && sed -i "s@export JAVA_HOME=\(.*\)@export JAVA_HOME=\1\nexport CLASSPATH=\$JAVA_HOME/lib/tools.jar:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib@" /etc/profile | |
[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep '$JAVA_HOME/bin' /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=\$JAVA_HOME/bin:\1@" /etc/profile | |
[ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile | |
. /etc/profile | |
echo "installed successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment