title: How to handle "[ERROR] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space" in JENKINS?
body: <p>I have been building GWT war file on Jenkins. In a specific "job" I have encountered an error which says <code>[ERROR] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space</code>. As a solution, I have included an environment variable "MAVEN_OPTS" with a value of <code>-Xms512m -Xmx1024m -XX:MaxPermSize=512m</code>. FYI, I have also tried 'echo' command prompt for MAVEN_OPTS and it displays the same value as I had given in the environment variable.</p>
  
  <p><strong>MAVEN COMPILER PLUGIN in pom.xml :</strong></p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.3.2&lt;/version&gt;
      &lt;configuration&gt;
      &lt;source&gt;1.7&lt;/source&gt;
      &lt;target&gt;1.7&lt;/target&gt;
      &lt;showDeprecation&gt;true&lt;/showDeprecation&gt;
      &lt;showWarnings&gt;true&lt;/showWarnings&gt;
      &lt;executable&gt;${env.JAVA_HOME}/bin/javac&lt;/executable&gt;
      &lt;fork&gt;true&lt;/fork&gt;
      &lt;verbose&gt;true&lt;/verbose&gt;
      &lt;encoding&gt;UTF-8&lt;/encoding&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>**Full error: **</p>
  
  <pre><code>[INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 13:51.518s
  [INFO] Finished at: Thu Jan 29 13:06:25 IST 2015
  [INFO] Final Memory: 17M/989M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-              plugin:2.4.0:compile
  (default) on project dpgwtwebapplication: Command [[
  [ERROR] C:\Program Files\Java\jdk1.7.0_04\jre\bin\java -Xmx512m -classpath    "C:\U
  </code></pre>
  
  <p>Also in mvn.bat file, the value of MAVEN_OPTS is displaying as <code>-Xmx512m</code> as you can notice in last of Full error.</p>