MAVEN maxheapsize doesn't change (JAVA 11 & CENTOS 7)

Viewed 83

I've been trying to build a maven project using JAVA 11 on CentOS 7.

When ran "mvn clean install" at the first time, I got an error

Error assembling JAR: Problem creating jar: Execution exception: Java heap space

So, I've been try to search for solutions on the internet. I've found that a lot of people do like

export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"

And it's working. Then, I tried this solution and build the project again. But it's not working. It still shows the same error. There's an info log shows "Final Memory: 218M/239M".

I tried export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m" a lot of time but it's not working.

After that, I've found that we can check the maxHeapSize by using command

java -XX:+PrintFlagsFinal -version | grep HeapSize

I got size_t MaxHeapSize = 260046848

It seems like the command MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m" doesn't work normally. Or I did something wrong. Please help.

1 Answers

I just need to do the

export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"

by root user. I need to add sudo before using the command.

sudo export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=128m"

Related