Installing JAVA Under Windows Linux Subsystem

June 12, 2017 3:22 pm Leave your thoughts

If you have seen my previous article, you’ll deduce that I have been playing around with the Ubuntu subsystem under Windows 10. One thing that I have to do in order to get some of my projects to work is to actually install JAVA. 

The thing about the Linux subsystem is that it’s actually a separate system running with your Windows, therefore if you have installed JAVA in Windows, it won’t carry over to the subsystem. At least for my case.

I had to research a bit to get JAVA going so here is a step-by-step instruction for you:

  1. Download the latest JAVA SDK. You can do this as usual from your browser.
    Download from:
  2. Open PowerShell, then type bash
  3. Within your bash terminal, copy the tgz file from /mnt/c/Users/<your windows username>/Downloads/jdk-8u131-linux-x64.tar.gz into /home/<your subsystem username/jdk-8u131-linux-x64.tar.gz
  4. Go back to your home folder: cd ~
  5. Extract the package: tar xvzf jdk-8u131-linux-x64.tar.gz
  6. Set the environment variables
    1. Open your bashrc file: sudo vim ~/.bashrc
    2. Add your java directory to the PATH and add JAVA_HOME right at the end.
    3. It will look like below:
      export PATH=~/jdk1.8.0_131/bin/:$PATH
      export JAVA_HOME=~/jdk1.8.0_131

If you run java -version, you should now see the correct java binary being ran and not the open-jdk version.


Categorised in: