问题:
当我通过Inno安装程序批量执行时,我遇到了Maven错误“JAVA_HOME环境变量定义不正确”的问题。但是,在Inno Setup之外,我可以成功运行(例如命令行、批处理文件和VBS)。我无法确定问题所在。
Inno Setup调用提示:
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
常规命令提示符:
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"
来自InnoSetup的Maven命令:
[Files]
Source: "C:\@Setup\MavenInstaller.bat"; DestDir: "{tmp}"; Flags: ignoreversion
[Run]
Filename: "{cmd}"; Parameters: "/C ""{tmp}\MavenInstaller.bat"""
批处理文件中的Maven命令:
mvn archetype:generate -DgroupId=com.mycompany.mycomponent-DartifactId=%APPLICATION_NAME% -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
设置JAVA_HOME
检查是否安装了Java 1.8。如果没有安装,请先安装并按照以下步骤设置JAVA HOME。
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
许多感谢。