When trying to use the Linux version of Oracle\'s JDK on the latest Windows 10 build having support for bash, I am running into a problem with the prompt hanging whenever at
A lot of answers are recommending installing the Linux JDK even though they have a perfectly good Windows JDK. The beauty of WSL is preventing you from having to do things like this, as the file systems are interoperable. As long as you take the file extensions into account (outlined below), you would only have to install both for niche situations.
You can do this very simply by adding the following line of code to your .bashrc file, assuming that your Windows Environment variables are set correctly and WSL is installed:
# Shared environment variables
export JAVA_HOME=/mnt/d/Java/jdk11.0.4_10
Just ensure that you change the directory to point to your JDK folder. In my case, it's in D:\Java\jdk11.0.4_10 which in WSL is /mnt/d/Java/jdk11.0.4_10
Also, since you're using Windows binaries, you must specify the file type when running from a WSL bash shell:
Calling Windows JDK from:
CMD:
javac MyClass.java
java MyClass
WSL:
javac.exe MyClass.java
java.exe MyClass
Note WSL requires .exe since it is a Windows binary. When using the Linux distro of the OpenJDK, no extension is required..