The Problem
I follow the stanbol tutorial to build stanbol.
export MAVEN_OPTS="-Xmx1024M -XX:MaxPermSize=256M"
As I am building stanbol in Windows, so I changed it to:
set MAVEN_OPTS="-Xmx1024M -XX:MaxPermSize=256M"
Then whenI run "mvn clean install -Dmaven.test.skip=true", it failed with error:
Invalid maximum heap size: -Xmx1024M -XX:MaxPermSize=256M
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
The Solution
Check mvn.bat: the MAVEN_OPTS is passed as JVM parameter directly:
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
If we run set MAVEN_OPTS="-Xmx1024M -XX:MaxPermSize=256M",the previous command would be replaced with %MAVEN_JAVA_EXE% "-Xmx1024M -XX:MaxPermSize=256M" ...
If we run java "-Xmx1024M -XX:MaxermSize=256M" -version: we will see same error message.
The solution is simple:
We can run:
set "MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=256M"
or remove the double quotes completely:
set MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=256M
The value of MAVEN_OPTS would be with no surrounding double quotes.
Now, we know why windows version batch file (mvn.bat) failed. But why the Linux version succeed? Check Linux shell file: mvn: it doesn't call java command directly, but call exec command.
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "${M2_HOME}"/boot/plexus-classworlds-*.jar \
"-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
"-Dmaven.home=${M2_HOME}" \
${CLASSWORLDS_LAUNCHER} "$@"
Compile Using Memory Allocation Enhancements in pom.xml
I follow the stanbol tutorial to build stanbol.
export MAVEN_OPTS="-Xmx1024M -XX:MaxPermSize=256M"
As I am building stanbol in Windows, so I changed it to:
set MAVEN_OPTS="-Xmx1024M -XX:MaxPermSize=256M"
Then whenI run "mvn clean install -Dmaven.test.skip=true", it failed with error:
Invalid maximum heap size: -Xmx1024M -XX:MaxPermSize=256M
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
The Solution
Check mvn.bat: the MAVEN_OPTS is passed as JVM parameter directly:
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
If we run set MAVEN_OPTS="-Xmx1024M -XX:MaxPermSize=256M",the previous command would be replaced with %MAVEN_JAVA_EXE% "-Xmx1024M -XX:MaxPermSize=256M" ...
If we run java "-Xmx1024M -XX:MaxermSize=256M" -version: we will see same error message.
The solution is simple:
We can run:
set "MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=256M"
or remove the double quotes completely:
set MAVEN_OPTS=-Xmx1024M -XX:MaxPermSize=256M
The value of MAVEN_OPTS would be with no surrounding double quotes.
Now, we know why windows version batch file (mvn.bat) failed. But why the Linux version succeed? Check Linux shell file: mvn: it doesn't call java command directly, but call exec command.
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "${M2_HOME}"/boot/plexus-classworlds-*.jar \
"-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \
"-Dmaven.home=${M2_HOME}" \
${CLASSWORLDS_LAUNCHER} "$@"
Compile Using Memory Allocation Enhancements in pom.xml