Skip to content

Instantly share code, notes, and snippets.

@gomin1d
Last active April 1, 2023 17:00
Show Gist options
  • Save gomin1d/12beb5009bd9c3c559176008daa688c6 to your computer and use it in GitHub Desktop.
Save gomin1d/12beb5009bd9c3c559176008daa688c6 to your computer and use it in GitHub Desktop.
Installing oracle java on linux

Install instructions

# Connect to your server as root via SSH
ssh root@your.server
# Install dependency 
apt-get install curl wget -y
# Download installation script
curl -O https://gist.githubusercontent.com/gomin1d/12beb5009bd9c3c559176008daa688c6/raw/java-install.sh
# Run it
bash java-install.sh
# Apply environment variables without reopening an SSH session
source /etc/profile.d/java.sh
#!/bin/bash
MACHINE_TYPE=`uname -m`
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
JAVA_DOWNLOAD_URL="https://www.dropbox.com/s/raw/ccn5w29df56lamf/jre-8u221-linux-x64.tar.gz"
else
JAVA_DOWNLOAD_URL="https://www.dropbox.com/s/raw/c71p18q10tz5soi/jre-8u221-linux-i586.tar.gz"
fi
wget -O jre.tar.gz ${JAVA_DOWNLOAD_URL}
mkdir -p /usr/java
tar -xzvf jre.tar.gz -C /usr/java
rm jre.tar.gz
echo -e "JAVA_HOME=`ls -d /usr/java/* | grep jre | head -1`\nPATH=\$PATH:\$HOME/bin:\$JAVA_HOME/bin\nexport JAVA_HOME\nexport PATH" > /etc/profile.d/java.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment