Skip to content

Instantly share code, notes, and snippets.

Created March 6, 2019 16:02
Show Gist options
  • Save Sawaba/22f3c3d4ec9a12dd972c2ecc71e4eca9 to your computer and use it in GitHub Desktop.
Save Sawaba/22f3c3d4ec9a12dd972c2ecc71e4eca9 to your computer and use it in GitHub Desktop.
Java JDK 11 install script for Windows Subsystem for Linux (WSL)
# This script adapted from an older post on StackOverflow by user fieldju
# The script was for JDK 8.
# Due to major changes with JDK 11 (no JRE, no Derby, Unlimited Strength included), it was necessary to update the entire script.
set -ex
# UPDATE THESE URLs (this one updated as of 2019-03-06)
export JDK_URL=
# Download Oracle Java 11 accepting the license
wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" \
# Extract the archive
tar -xzvf jdk-*.tar.gz
# clean up the tar
rm -fr jdk-*.tar.gz
# mk the jvm dir
sudo mkdir -p /usr/lib/jvm
# move the server jre
sudo mv jdk-11.* /usr/lib/jvm/oracle_jdk11
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/oracle_jdk11/bin/java 2000
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/oracle_jdk11/bin/javac 2000
sudo echo "export J2SDKDIR=/usr/lib/jvm/oracle_jdk11
export J2REDIR=/usr/lib/jvm/oracle_jdk11/
export PATH=$PATH:/usr/lib/jvm/oracle_jdk11/bin
export JAVA_HOME=/usr/lib/jvm/oracle_jdk11" | sudo tee -a /etc/profile.d/
Copy link

Thanks for the updated script.
Please escape the $PATH variable on line 28. There is no need to expose the exact PATH value here. The line should look like:
export PATH=\$PATH:/usr/lib/jvm/oracle_jdk11/bin

Copy link

Argg... it gives me a 404 error at the end...

Connecting to (||:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2020-03-17 20:58:11 ERROR 404: Not Found.

Copy link

Anyone still using this: you can simply download it through the browser on your windows 10 machine, and then on your WSL navigate to /mnt/ which is where you drives are mounted, then you can copy the .tar.gz file from your mounted drive to your WSL folders, wherever you want it. Then just run the rest of the script and you should be ok

Copy link

you have to just replace the JDK_URL with a new one. This script is a bomb.
I have used this JDK_URL:

Copy link

What's the AuthParam? Do you have to sign up to get it?

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