1

Operating System Windows 10 java version "1.8.0_161" - jre

C:\Users\admin>echo %JAVA_HOME% C:\Program Files\Java\jdk1.8.0_91\;

Error (Command line)
C:\Users\admin>mvn -version
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
  • Did you google what the error means and how it can be removed. It's pretty simple though – demouser123 Apr 19 '18 at 13:57
  • I am getting the same error. My environment path is C:\Program Files\Java\jdk1.8.0_201\ Even i have tried removing "\" but still the same error. 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 Please help me to resolve this error. Thanks – Venkat Mar 28 '19 at 11:18
3

Get rid of the trailing backslash and especially the trailing semi-colon:

C:\Program Files\Java\jdk1.8.0_91

By the way, you can display the current setting with the shorthand of typing "set" at a command prompt followed by the minimal number of characters needed, i.e. on my system:

set j
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144
| improve this answer | |
  • Thanks Bill, removing trailing backslash and semi colon solves the problem – Sudeept Apr 19 '18 at 14:55
  • Trailing slash was my issue. I thought it was a problem with windows path in git bash, but it was just the slash, thanks Bill. – mtyson Jan 2 at 22:35
0

I had the same issue. Please remove the backslash('') and semicolon.

For windows 10, here are the steps:

  1. Open Environment Variables
  2. Select 'JAVA_HOME' under system variables
  3. Click Edit
  4. Remove the \; from path under the 'variable name'.
  5. Click 'OK'

Done. RUN the mvn -version command and it shall work.

| improve this answer | |

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.