Created
August 30, 2017 20:54
-
-
Save shlomiv/dbaf78afa0d09dcc8a9cf24891490060 to your computer and use it in GitHub Desktop.
Install java 8 on an emr machine automatically.
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
# Check java version | |
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q') | |
if [ "$JAVA_VER" -lt 18 ] | |
then | |
echo "Getting add-apt-repository" | |
wget --no-check-certificate --no-cookies "https://blog.anantshri.info/content/uploads/2010/09/add-apt-repository.sh.txt" -O add-apt-repository.sh | |
echo "Adding oracle java ppa" | |
sudo sh add-apt-repository.sh ppa:webupd8team/java | |
echo "updating" | |
sudo apt-get update | |
echo "Setting up installation..." | |
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections | |
echo "Installing..." | |
sudo apt-get install -y oracle-java8-installer | |
echo "Setting JAVA_HOME to java 8" | |
echo 'export JAVA_HOME=/usr/lib/jvm/java-8-oracle' > /home/hadoop/conf/hadoop-user-env.sh | |
fi | |
# Check java version again | |
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q') | |
echo "" | |
echo "Java version is $JAVA_VER!" | |
echo "JAVA_HOME: $JAVA_HOME" | |
echo "JRE_HOME: $JRE_HOME" | |
echo "PATH: $PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment