Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the MAVEN_OPTS environment variable do? [closed]

Tags:

java

maven

For example:-

MAVEN_OPTS=" -Xms512m -Xmx1024m -XX:MaxPermSize=1024m"
export MAVEN_OPTS

What does "-Xms512m -Xmx1024m -XX:MaxPermSize=1024m" mean?

like image 495
tk_ Avatar asked Sep 02 '14 10:09

tk_


People also ask

What is MAVEN_OPTS environment variable?

MAVEN_OPTS environment variable: This variable contains parameters used to start up the JVM running Maven and can be used to supply additional options to it. E.g. JVM memory settings could be defined with the value -Xms256m -Xmx512m .

What environment variable can you alter to increase the memory Maven uses?

You can start Maven with extra memory using MAVEN_OPTS environment variable.

What is M2_HOME environment variable?

M2_HOME is used by Maven, and again it tells the program where to find Maven installation. PATH is not suitable for that purpose, because it may contain many directories not related to Java or Maven.

What is environment variable in POM XML?

To refer to environment variables from the pom. xml, we can use the ${env. VARIABLE_NAME} syntax. We should remember to pass the Java version information via environment variables.


2 Answers

After going through above comments, I clarify my doubts about MAVEN_OPTS and maven semantics. The MAVEN_OPTS environment variable contains parameters used to start up the JVM running Maven and can be used to supply additional options. This includes JVM memory pool parameters. Kindly refer this link and go through the document.

    -Xmsn
            Specifies the initial size, in bytes, of the memory allocation pool. This value 
must be a multiple of 1024 greater than 1 MB. Append the letter k or K to indicate kilobytes,
 or m or M to indicate megabytes. The default value is chosen at runtime based on system configuration. See Garbage Collector Ergonomics at
            [http://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html][2]
            
            Examples:
            
            -Xms6291456
            -Xms6144k
            -Xms6m
    
      -Xmxn
            Specifies the maximum size, in bytes, of the memory allocation pool. This value 
must a multiple of 1024 greater than 2 MB. Append the letter k or K to indicate kilobytes, or m
 or M to indicate megabytes. The default value is chosen at runtime based on system 
configuration.
            
            For server deployments, -Xms and -Xmx are often set to the same value. See Garbage
 Collector Ergonomics at
            [http://docs.oracle.com/javase/7/docs/technotes/guides/vm/gc-ergonomics.html][3]
            
            Examples:
            
            -Xmx83886080
            -Xmx81920k
            -Xmx80m
like image 50
tk_ Avatar answered Oct 09 '22 10:10

tk_


Documentation is great but it is not always complete. There are some additional things which you can do to figure things out yourself. In this case you know that MAVEN_OPTS is an environmental variable, which likely means it is used in shell script. So open up for example mvn.bat and search for MAVEN_OPTS to see how it is used.

You will find it is simply a way to specify Java command line arguments which will be in effect for the execution of Maven itself. As an example in the past I needed to increase the default permgen size to prevent issues during execution of a complex build.

like image 32
Gimby Avatar answered Oct 09 '22 09:10

Gimby