Skip to content

Instantly share code, notes, and snippets.

@cbarraco
Last active December 29, 2015 10:08
Show Gist options
  • Save cbarraco/7654510 to your computer and use it in GitHub Desktop.
Save cbarraco/7654510 to your computer and use it in GitHub Desktop.
Uninstalls OpenJDK and Installs the Oracle JRE & JDK and the Android SDK & NDK in Ubuntu. Basically a script version of http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux with the Android SDK and NDK thrown in.
echo "*******************************************"
echo "********** Uninstalling Open-JDK **********"
echo "*******************************************"
sudo apt-get purge openjdk-\*
echo "***************************************"
echo "********** Downloading Files **********"
echo "***************************************"
wget "http://dl.google.com/android/android-sdk_r22.6.2-linux.tgz"
wget "http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2"
echo "*****************************************"
echo "********** Extracting Archives **********"
echo "*****************************************"
tar xvzf "jre-8u5-linux-x64.tar.gz"
tar xvzf "jdk-8u5-linux-x64.tar.gz"
tar xvzf "android-sdk_r22.6.2-linux.tgz"
tar xvjf "android-ndk-r9d-linux-x86_64.tar.bz2"
echo "*********************************************"
echo "********** Copying Files to System **********"
echo "*********************************************"
sudo mkdir -p /usr/local/java
sudo mkdir -p /usr/local/android
sudo cp -rv "jdk1.8.0_05" /usr/local/java/
sudo cp -rv "jre1.8.0_05" /usr/local/java/
sudo chown -R `whoami` /usr/local/java
sudo cp -rv "android-sdk-linux" /usr/local/android/
sudo cp -rv "android-ndk-r9d" /usr/local/android/
sudo chown -R `whoami` /usr/local/android
echo "**************************************************"
echo "********** Adding Environment Variables **********"
echo "**************************************************"
echo 'JAVA_HOME=/usr/local/java/jdk1.8.0_05' | sudo tee -a /etc/environment
echo 'JRE_HOME=/usr/local/java/jre1.8.0_05' | sudo tee -a /etc/environment
echo 'ANDROID_HOME=/usr/local/android/android-sdk-linux' | sudo tee -a /etc/environment
echo 'NDK_HOME=/usr/local/android/android-ndk-r9d' | sudo tee -a /etc/environment
echo 'PATH=$PATH:$HOME/bin:$JAVA_HOME/bin' | sudo tee -a /etc/bash.bashrc
echo 'PATH=$PATH:$HOME/bin:$JRE_HOME/bin' | sudo tee -a /etc/bash.bashrc
echo 'PATH=$PATH:$HOME/bin:$ANDROID_HOME/platform-tools' | sudo tee -a /etc/bash.bashrc
echo 'PATH=$PATH:$HOME/bin:$NDK_HOME/' | sudo tee -a /etc/bash.bashrc
echo 'export PATH' | sudo tee -a /etc/bash.bashrc
echo "*********************************************"
echo "********** Setting System Defaults **********"
echo "*********************************************"
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.8.0_05/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_05/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.8.0_05/bin/javaws" 1
sudo update-alternatives --set java /usr/local/java/jre1.8.0_05/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_05/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jre1.8.0_05/bin/javaws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment