How to increase java heap space on Maven

java.lang.OutOfMemoryError: java heap space while building our project either by using maven or ANT just because heap size is not enough to build the project. At this point we just want to increase the heap size used by ANT or MAVEN and this java tip will let you do this:

For Linux
Open your mvn.sh file and add the following line:
export MAVEN_OPTS=-Xmx1024m
this will allow to specify java heap space based on your project needs.

For Windows
1. go to C:\apache-maven-2.2.1\bin
2. open your mvn.bat file and add the following line :
set MAVEN_OPTS=-Xmx512m
next time you run maven commands like mvn clean or mvn install it will use this heap size.

You can also set MAVEN_OPTS in environment variable in window/linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s