Last active
July 15, 2022 03:35
-
-
Save Just-a-Unity-Dev/a2c2d739ab98ebec627e702ee76a077c to your computer and use it in GitHub Desktop.
A little install script I like to use which installs Java 18
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
#!/bin/bash | |
NC="\033[0m" | |
RED="\033[0;31m" | |
GREEN="\033[0;32m" | |
YELLOW="\033[1;33m" | |
if [ "$(id -u)" -ne 0 ] | |
then echo "${RED}Error! ${YELLOW}Please run this script again as root." | |
exit 1 | |
fi | |
wget https://github.com/adoptium/temurin18-binaries/releases/download/jdk-18.0.1%2B10/OpenJDK18U-jdk_x64_linux_hotspot_18.0.1_10.tar.gz | |
sudo mkdir /usr/java | |
sudo mv OpenJDK18U-jdk_x64_linux_hotspot_18.0.1_10.tar.gz /usr/java | |
cd /usr/java | |
sudo tar -xzvf OpenJDK18U-jdk_x64_linux_hotspot_18.0.1_10.tar.gz | |
sudo echo "JAVA_HOME=/usr/java/jdk-18.0.1+10" > /etc/profile | |
sudo echo "PATH=$PATH:$HOME/bin:$JAVA_HOME/bin" > /etc/profile | |
sudo echo "export JAVA_HOME" > /etc/profile | |
sudo echo "export JRE_HOME" > /etc/profile | |
sudo echo "export PATH" > /etc/profile | |
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-18.0.1+10/bin/java" 1 | |
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-18.0.1+10/bin/javac" 1 | |
cd ~ | |
echo "${GREEN}Successfully installed Java 18.0.1_10${NC}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment