Issue
I downloaded Maven from the following link: Maven Download.
I set my PATH variables as follows:
echo %JAVA_HOME%
C:\Program Files\Java\jdk-17.0.2\bin
echo %MAVEN_HOME%
C:\Program Files\Apache\Maven-3.8.4
When I run the command:
mvn -version
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.
Here is the output of my PATH:
echo %PATH%
C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\MongoDB\Server\4.2\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\PuTTY\;C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\Azure Data Studio\bin;C:\Program Files\nodejs\;C:\Program Files\Graphviz\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\dotnet\;C:\Program Files (x86)\Calibre2\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk-17.0.2\bin;C:\Program Files\Java\javafx-sdk-17.0.2\lib;C:\Program Files\Apache\Maven-3.8.4\bin;C:\Users\Troy Pilewski\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\Troy Pilewski\AppData\Local\Programs\Python\Python310\;C:\Users\Troy Pilewski\scoop\shims;C:\Ruby27-x64\bin;C:\Users\Troy Pilewski\AppData\Local\Microsoft\WindowsApps;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.3.3\bin;C:\Users\Troy Pilewski\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Troy Pilewski\AppData\Local\atom\bin;C:\Users\Troy Pilewski\.dotnet\tools;C:\Program Files (x86)\Nmap;C:\Users\Troy Pilewski\AppData\Roaming\npm;C:\Users\Troy Pilewski\AppData\Local\GitHubDesktop\bin;C:\Users\Troy Pilewski\AppData\Local\gitkraken\bin;C:\Users\Troy Pilewski\.dotnet\tools;C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.3.2\bin;C:\Users\Troy Pilewski\AppData\Local\Microsoft\WindowsApps
How do I fix my JAVA_HOME path error when I run the mvn -version command?
Solution
JAVA_HOME=C:\Program Files\Java\jdk-17.0.2
Drop the "bin"
Answered By - Khanna111
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)