Installing Oracle JDK on Windows subsystem for Linux Installing Oracle JDK on Windows subsystem for Linux linux linux

Installing Oracle JDK on Windows subsystem for Linux


I wanted to clarify that as of 9 December 2016, you most certainly can install Java 8 on Ubuntu Bash for Windows 10 and that @Karl Horton is correct.

You will need to install unzip sudo apt-get install unzip

Copy this script somewhere in your bash for windows session and make it executable (chmod +x filename). If you do not use a command line based editor such as vim then you will have windows line endings to deal with. you can use dos2unix or your preferred way of dealing with that. I just paste it into a file using vim.

 #!/bin/bashset -ex# UPDATE THESE URLsexport JDK_URL=http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gzexport UNLIMITED_STRENGTH_URL=http://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip# Download Oracle Java 8 accepting the licensewget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" \${JDK_URL}# Extract the archivetar -xzvf jdk-*.tar.gz# clean up the tarrm -fr jdk-*.tar.gz# mk the jvm dirsudo mkdir -p /usr/lib/jvm# move the server jresudo mv jdk1.8* /usr/lib/jvm/oracle_jdk8# install unlimited strength policywget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" \${UNLIMITED_STRENGTH_URL}unzip jce_policy-8.zipmv UnlimitedJCEPolicyJDK8/local_policy.jar /usr/lib/jvm/oracle_jdk8/jre/lib/security/mv UnlimitedJCEPolicyJDK8/US_export_policy.jar /usr/lib/jvm/oracle_jdk8/jre/lib/security/sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/oracle_jdk8/jre/bin/java 2000sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/oracle_jdk8/bin/javac 2000sudo echo "export J2SDKDIR=/usr/lib/jvm/oracle_jdk8export J2REDIR=/usr/lib/jvm/oracle_jdk8/jreexport PATH=$PATH:/usr/lib/jvm/oracle_jdk8/bin:/usr/lib/jvm/oracle_jdk8/db/bin:/usr/lib/jvm/oracle_jdk8/jre/binexport JAVA_HOME=/usr/lib/jvm/oracle_jdk8export DERBY_HOME=/usr/lib/jvm/oracle_jdk8/db" | sudo tee -a /etc/profile.d/oraclejdk.sh

And now I can do the following

fieldju@DESKTOP-LTL6MIC:~$ java -versionjava version "1.8.0_112"Java(TM) SE Runtime Environment (build 1.8.0_112-b15)Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)                                                

The links and versions in the above script are likely to be out of date by the time you read this, so just head over to http://www.oracle.com/technetwork/java/javase/downloads/index.html accept the license so that their js lets you copy the new URLs and you should be good to go.


It seems in 2017 august the solution is simpler as suggested by @noah-david.

I was able to install Oracle JDK 8 from the “WebUpd8” team repository.

Instructions. To add the repository:

sudo add-apt-repository ppa:webupd8team/javasudo apt-get update

To install:

sudo apt-get install oracle-java8-installer sudo apt install oracle-java8-set-default

After install

costin@amanta-win:/mnt/c/work$ java -versionjava version "1.8.0_144"Java(TM) SE Runtime Environment (build 1.8.0_144-b01)Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)costin@amanta-win:/mnt/c/work$ which java/usr/bin/javacostin@amanta-win:/mnt/c/work$ uname -aLinux amanta-win 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014   x86_64 x86_64 x86_64 GNU/Linux


I must be missing something... all I did was:

sudo apt-get updatesudo apt-get install default-jdkjava -version

output:

java version "1.7.0_131"OpenJDK Runtime Environment (IcedTea 2.6.9) (7u131-2.6.9-0ubuntu0.14.04.2)OpenJDK 64-Bit Server VM (build 24.131-b00, mixed mode)