Issue:
I am getting the Maven error \"The JAVA_HOME environment variable is not defined correctly\" when I run through Inno setup batch execution. Howe
A very common mistake people make is that, when they set JAVA_HOME
or JRE_HOME
, they set the value to C:\Program Files\Java\jdk1.8.0_221\bin
or similar.
Please note JAVA_HOME
and JRE_HOME
value should not contain \bin
It seems that Maven doesn't like the JAVA_HOME
variable to have more than one value. In my case, the error was due to the presence of the additional path C:\Program Files\Java\jax-rs
(the whole path was C:\Program Files\Java\jdk1.8.0_20;C:\Program Files\Java\jax-rs
).
So I deleted the JAVA_HOME
variable and re-created it again with the single value C:\Program Files\Java\jdk1.8.0_20
.
Following is the best way to get of the issue , check following on classpath:
Make sure JAVA_HOME system variable must have till jdk e.g C:\Program Files\Java\jdk1.7.0_80
, don't append bin here.
Because MAVEN will look for jre which is under C:\Program Files\Java\jdk1.7.0_80
Set %JAVA_HOME%\bin
in classpath .
Then try Maven version .
Hope it will help .
My JDK is installed at C:\Program Files\Java\jdk1.8.0_144\
.
I had set JAVA_HOME= C:\Program Files\Java\jdk1.8.0_144\
,
and I was getting this 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
When I changed the JAVA_HOME
to C:\Program Files\Java\jdk1.8.0_144\jre
, the issue got fixed.
I am not sure how.
I have removed JAVA_HOME variable and kept only path and classpath variables by pointing them to jdk and jre respectively. It worked for me.
SET JAVA_HOME=C:\Program Files\Java\jdk1.8.0
worked fine for me.
Note - Don't put double quotes over the path as mentioned above. Otherwise when you run
mvn -version
it will give following error
Files\java\jdk1.8.0_201\jre""==""
was unexpected at this time.