I have JDK 11 and Maven 3.8.1 installed on my Windows 10 machine. Took care that install paths don't have spaces.
Made the value of JAVA_HOME
visible inside the Ubuntu shell following the advice here. Then I restarted the Ubuntu shell.
Here are the outputs from inside an Ubuntu shell on Windows Terminal:
user@computer:/path$ java -version
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)
user@computer:/path$ env | grep JAVA
JAVA_HOME=/mnt/c/AdoptOpenJDK/jdk-11-hotspot
user@computer:/path$ mvn -v
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
So although the value of JAVA_HOME
is visible inside the Ubuntu shell, somehow mvn
can't see it. How do I fix this?
Maven run from cmd
gives this output:
C:\path>mvn -v
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: C:\Maven\bin\..
Java version: 11.0.10, vendor: AdoptOpenJDK, runtime: C:\AdoptOpenJDK\jdk-11-hotspot
Default locale: en_IN, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Versions:
- Windows 10 version 2004 (OS Build 19041.1110)
- Java 11.0.10
- Maven 3.8.1
- WSL2
- Ubuntu 20.04.2 LTS (via WSL2)