Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven heap space

Tags:

java

maven

When I am running mvn clean install for my build on linux RHEL 6. I'm getting the following error: java.lang.outOfMemoryError heap space.

I have read all the articles on internet. On my machine I dont have a file called mvn.sh, I only have a file mvn.bat.

Where can I set the export MAVEN_OPTS command?

like image 938
user1858798 Avatar asked Nov 28 '12 06:11

user1858798


Video Answer


2 Answers

You can run the mvn command, so its irrelevant wether you are using a .sh or .bat file. For future reference you should keep in mind though that .bat files are for Windows, not Linux. Anyway, in the same shell you are running your mvn command in, do this first:

export MAVEN_OPTS="-Xmx512M"

Then execute your mvn command. Bump the number up if you still run out of memory.

like image 133
Perception Avatar answered Dec 06 '22 02:12

Perception


When I am running mvn clean install for my build on linux RHEL 6 it is showing java.lang.outOfMemoryError heap space.

You need to set the MAVEN_OPTS environment variable.

I have read all the articles on internet

That is false. At best you have read a TINY FRACTION of the relevant articles.

... and in my machine I don't have mvn.sh, I have mvn.bat

If you have used "yum" to install Maven, then there will be a "mvn" command on your command path. On my system, it is a shell script. If you were going to "hack" a script, that would what you would edit.

But you shouldn't need to.

and where to set export MAVEN_OPTS COMMAND.

This is a very basic "How to use a Linux command shell" question.

The answer is either you type is at the command prompt before you run the "mvn" command, or you add it to your shell initialization file and restart the shell as appropriate.


My advice would be to invest some time in reading a tutorial about how to use the Linux command shell. It will save you a lot of time in the long term.

like image 24
Stephen C Avatar answered Dec 06 '22 02:12

Stephen C