Issue:
I am getting the Maven error "The JAVA_HOME environment variable is not defined correctly" when I run through Inno setup batch execution. However, I am able to run successfully outside Inno Setup.(e.g Command line, Batch file, Vbs). I am clueless to identify the issue.
Inno Setup Invoked Prompt:
C:\>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
Regular Command Prompt:
C:\>mvn -version
C:\
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T01:09:06+05:30)
Maven home: C:\Program Files\apache-maven-3.5.0\bin\..
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_131\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Maven Command from InnoSetup:
[Files]
Source: "C:\@Setup\MavenInstaller.bat"; DestDir: "{tmp}"; Flags: ignoreversion
[Run]
Filename: "{cmd}"; Parameters: "/C ""{tmp}\MavenInstaller.bat"""
Maven Command from Batch File:
mvn archetype:generate -DgroupId=com.mycompany.mycomponent-DartifactId=%APPLICATION_NAME% -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Setting JAVA_HOME
Check the If Java 1.8 is installed or not. If not installed, Install the same and set the JAVA HOME as follows.
SETX JAVA_HOME "C:\Program Files\Java\jdk1.8.0_131"
SETX -m JAVA_HOME "C:\Program Files\Java\jdk1.8.0_131"
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_SZ /d "%path%;C:\Program Files\Java\jdk1.8.0_131\bin;" /f
Many Thanks.
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.