Sometimes you may experience the following error when running ‘mvn clean install’ when building a project.

[INFO] [ERROR] Unexpected
[INFO] java.lang.OutOfMemoryError: Java heap space

You can avoid this by increasing the Xmx by setting the MAVEN_OPTS as follows,

export MAVEN_OPTS=”-Xms1024m -Xmx2048m -XX:PermSize=1024m”

You can simply add the MAVEN_OPTS as an environment variable by editing the .bashrc file. additionally you need to check whether your RAM size is enough to allocate above heap size for maven.

--

--

No responses yet