Skip to content

Instantly share code, notes, and snippets.

@ricardojlrufino
Created May 30, 2015 16:07
Show Gist options
  • Save ricardojlrufino/1f9b15f84491a0131274 to your computer and use it in GitHub Desktop.
Save ricardojlrufino/1f9b15f84491a0131274 to your computer and use it in GitHub Desktop.
Script to Setup JAVA (on rapberry, beaglebone, etc...)
#!/bin/bash
DFILE=`find -name "*arm*.tar.gz"`
echo "Found: " $DFILE
if [ -z "$DFILE" ]; then
echo "ERROR: Please download JRE/JDK and put in current directory"
exit 1
fi
if grep -Fq "JAVA_HOME" ~/.profile
then
echo "ERROR: already found another installed version on ~/.profile, remove first"
exit 1
fi
mkdir /opt/java
tar -zxvf $DFILE -C /opt/java
JAVA_HOME=`ls -d /opt/java/*`
echo "Installed on: " $JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME=$JAVA_HOME
# Install on Profile
echo "export JAVA_HOME=$JAVA_HOME" >> ~/.profile
echo "export PATH=\$PATH:$JAVA_HOME/bin/" >> ~/.profile
echo "Finished ! Logout or run those commands:"
echo "=========================================="
echo "export JAVA_HOME=$JAVA_HOME"
echo "export PATH=\$PATH:$JAVA_HOME/bin/"
@ricardojlrufino
Copy link
Author

This script unpacks and sets up the environment variables and install the appropriate folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment