I'm not able to run the windows version of java.exe from BashOnWindows10. It is present in PATH, but the invocation fails silently. My goal is to avoid having to install the JDK/JRE again in WSL. As I'm running the Creator's update, I was was expecting the to be able to invoke any windows application. Any ideas why this is happening? I'm however able to launch the windows installation of Python successfully.


username@PC:~$ which java.exe

username@PC:~$ java.exe
username@PC:~$         <<<nothing happens

username@PC:~$ which python.exe

username@PC:~$ python.exe
Unable to translate current working directory. Using C:\WINDOWS\system32
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.


C:\Users\username>java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

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.

  • Superb! Before: Java -version gives Command 'Java' not found After: Java - version gives java version "1.8.0_151" I wish I could up this answer like 10 points instead of 1! – boardtc Nov 7 '18 at 14:53
  • 1
    Just a heads up that this will "confuse" and paths used in your Java program or as properties/inputs. E.g. "/tmp/somefile.txt" will be e.g. "c:/tmp/somefile.txt" when your Windows Java tries to execute it and result in file not found! – Anders May 31 '19 at 9:08

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


If you want to execute your java.exe inside the linux subsystem you can follow this answer: https://stackoverflow.com/a/54151117/2751561

If wat you want the other way around you can call the java bin on cmd like this:

wsl java -version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.