My Windows 10 machine recently forcibly upgraded me to the new "Creators Update" version of windows, the "About your PC" widget now reports my OS version as "1703".
I thought I would have a crack at using the Windows Subsystem for Linux / Ubuntu on Windows to compile my Gradle projects.
I have a Windows JDK installed at c:\jvm\jdk1.8.0_102
.
In my MinGW terminal window ("git bash"), I can setup a JAVA_HOME and execute the gradle wrapper script from my source directory and it will just work:
export JAVA_HOME=/c/jvm/jdk1.8.0_102
./gradlew tasks
But I can't figure out how to do an equivalent thing with WSL. Opening up the "Bash on Ubuntu on Windows" terminal, changing to my source directory and invoking the following:
export JAVA_HOME=/mnt/c/jvm/jdk1.8.0_102
./gradlew tasks
Results in the following:
ERROR: JAVA_HOME is set to an invalid directory: /mnt/c/jvm/jdk1.8.0_102
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
Note that the Windows JDK runs fine from within the bash terminal. Executing $JAVA_HOME/bin/java.exe -version
in the Ubuntu terminal will work fine.
The question is:
Is there any way to run my gradlew script from a "Bash on Ubuntu on Windows" terminal using the Windows JDK I've previously installed.
Please note:
I'm specifically asking if it's possible to get my Gradle script running using the Windows JDK, not an Ubuntu/Linux JDK installed with WSL. I understand I can likely run my gradle wrapper script by installing a Linux JDK within the Windows Sunbsystem for Linux, but I'm trying to figure out if it's possible to run my builds using the Windows JDK.
Just to make sure I didn't miss anything obvious, I downloaded Android Studio (which contains JDK, or rather, minimal set of Java tools to build Android projects) for Windows and Linux and installed them to 2 different directories: Windows version in C:\Program Files\Android\Android Studio
and Linux version in ~/android-studio
.
Inside WSL, I first set JAVA_HOME
to C:\Program Files\Android\Android Studio\jre
and ran gradlew
. It gave me invalid directory
error message.
Next, I set JAVA_HOME
to ~/android-studio/jre
. Everything worked as expected.
And then I copied Android Studio for Windows to ~/android-studio-windows
and set JAVA_HOME
to ~/android-studio-windows/jre
. It gave me the same invalid directory
error message, so I think WSL isn't able to use Windows tools as they are (well, at least not for the moment).
So, if your goal is to use gradle in WSL, I think you need to install OpenJDK for Linux (or something similar) inside WSL.
If you are using WSL and you want to run gradlew from WSL terminal then you can do it as follow:
cmd.exe /c gradlew --version
cmd.exe /c gradlew :help
cmd.exe /c gradlew app:dependencies
cmd.exe /c gradlew app:dependencies | grep -i "com.android.support"
I'm using windows version:
rdey@surface-book:/mnt/c/Users/rdey/git/ici$ cmd.exe /c "systeminfo" | grep "^OS Version"
OS Version: 10.0.17763 N/A Build 17763
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With