title: How do I fix maven error The JAVA_HOME environment variable is not defined correctly?
body: <p><strong>Issue:</strong> </p>
  
  <p>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.</p>
  
  <p><strong>Inno Setup Invoked Prompt:</strong></p>
  
  <pre><code>C:\&gt;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
  </code></pre>
  
  <p><strong>Regular Command Prompt:</strong></p>
  
  <pre><code>C:\&gt;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"
  </code></pre>
  
  <p><strong>Maven Command from InnoSetup:</strong></p>
  
  <pre><code>[Files]
  Source: "C:\@Setup\MavenInstaller.bat"; DestDir: "{tmp}"; Flags: ignoreversion
  [Run]
  Filename: "{cmd}"; Parameters: "/C ""{tmp}\MavenInstaller.bat"""
  </code></pre>
  
  <p><strong>Maven Command from Batch File:</strong></p>
  
  <pre><code>mvn archetype:generate -DgroupId=com.mycompany.mycomponent-DartifactId=%APPLICATION_NAME% -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
  </code></pre>
  
  <p><strong>Setting JAVA_HOME</strong></p>
  
  <p>Check the If Java 1.8 is installed or not. If not installed, Install the same and set the JAVA HOME as follows.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Many Thanks.</p>