Skip to content

Instantly share code, notes, and snippets.

@shlomiv
Created August 30, 2017 20:54
Show Gist options
  • Save shlomiv/dbaf78afa0d09dcc8a9cf24891490060 to your computer and use it in GitHub Desktop.
Save shlomiv/dbaf78afa0d09dcc8a9cf24891490060 to your computer and use it in GitHub Desktop.
Install java 8 on an emr machine automatically.
# 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