You are here

Setting MAVEN_OPTS & M2_HOME

Before using the SkyVault SDK, you need to set your MAVEN_OPTS and M2_HOME environment variables to suitable values using the correct mechanism for your operating system.
Setting M2_HOME specifies the home of Maven and is used by the script mvn (or mvn.bat on Windows). MAVEN_OPTS is used to configure a bit of extra memory for Maven as it will run an embedded Apache Tomcat application server with SkyVault Repo, Share, and Solr web applications deployed. It also sets the Spring Loaded Java Agent so it is available during Rapid Application Development (RAD).

Setting Variables.

  1. On Mac OS X you can edit your .bash_profile file and add the following:

    export M2_HOME=/home/martin/apps/apache-maven-3.3.3
    export MAVEN_OPTS="-Xms1024m -Xmx1G -XX:PermSize=1024m -javaagent:/home/martin/libs/springloaded-1.2.5.RELEASE.jar -noverify"
    Important: Remove -XX:PermSize=1024m if you are using JDK 8, it is only needed for JDK 7.
    Important: Refer to previous installation sections for in what directory Maven was installed and in what directory Spring Loaded was installed.

    Restart the terminal session or run source .bash_profile to activate the environment variables.

  2. On Linux you can edit your .bashrc file and add the following:

    See step 1 for Mac OS, do the same thing for Linux.

    Restart the terminal session or run source .bashrc to activate the environment variable.

  3. On Windows, the exact procedure for setting environment variables varies depending on the version of Windows you are running. For example, the procedure for Windows XP can be found in the Microsoft Knowledgebase.

    set M2_HOME=C:\Tools\apache-maven-3.3.1
    set MAVEN_OPTS=-Xms256m -Xmx1G -XX:PermSize=1024m -javaagent:C:\Tools\spring-loaded\springloaded-1.2.5.RELEASE.jar -noverify
    Important: Remove -XX:PermSize=1024m if you are using JDK 8, it is only needed for JDK 7.
    Important: If the path to the Spring Loaded JAR contains spaces, then you might need to double quote it like -javaagent:"C:\My Tools\spring-loaded\springloaded-1.2.5.RELEASE.jar". Refer to previous installation sections for in what directory Maven was installed and in what directory Spring Loaded was installed.

    Restart the Windows terminal/console session.

Verifying Variables.

  1. Ensure that the MAVEN_OPTS and M2_HOME environment variables are set correctly, using a method suitable for your system. For example, on Mac OS X and Linux you can enter the following command:

    $ env|egrep "M2|MAV"
    MAVEN_OPTS=-Xms256m -Xmx1G -XX:PermSize=1024m -javaagent:/home/martin/libs/springloaded-1.2.5.RELEASE.jar -noverify
    M2_HOME=/home/martin/apps/apache-maven-3.3.3

    Ensure that the result matches the value you specified in your shell configuration file (such as .bashrc).

    If you are on Windows you can use a command such as set M to display environment variables starting with 'M'.

    C:\Users\mbergljung>set M
    M2_HOME=C:\Tools\apache-maven-3.3.1
    MAVEN_OPTS=-Xms256m -Xmx1G -XX:PermSize=1024m -javaagent:C:\Tools\spring-loaded\springloaded-1.2.3.RELEASE.jar -noverify
Your MAVEN_OPTS and M2_HOME environment variables are now set. Feel free to increase the specified memory settings if required, for example, if you get "out of memory" errors when running your projects.