Installing JAVA Under Windows Linux Subsystem
June 12, 2017 3:22 pm Leave your thoughtsIf 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:
- Download the latest JAVA SDK. You can do this as usual from your browser.
Download from: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html - Open PowerShell, then type bash
- 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
- Go back to your home folder: cd ~
- Extract the package: tar xvzf jdk-8u131-linux-x64.tar.gz
- Set the environment variables
- Open your bashrc file: sudo vim ~/.bashrc
- Add your java directory to the PATH and add JAVA_HOME right at the end.
- 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: Coding