How to use the windows installation of java from BashOnWindows10?

Here's how I just made Java "just work" for my WSL installation.

ln -s /mnt/c/Program\ Files\ \(x86\)/Java/jre1.8.0_151/bin/java.exe /bin/java

What this does is create a symbolic link in your /bin folder to your Windows Java binary. Whenever WSL tries to invoke Java now, it's redirected to the Windows version. You will probably need to adjust the path as Java versions change in the future.


This issue is because WSL does not support windows shortcuts in the Creator's update. /mnt/c/ProgramData/Oracle/Java/javapath/java.exe is actually a shortcut to the actual installation directory which is C:\Program Files\Java\jre1.8.0_31\bin in my case. Invoking java from the actual installation path seems to work as expected.

This issue is resolved in build 16193