Setup Maven On Linux

Download the tarball for Maven 2.2.

On Linux, setup Maven as follows.

Untar the download in the directory where you wish to install Maven.

tar -zxvf apache-maven-2.2.1-bin.tar.gz

Setup the Maven environment. You may want to add these lines to your shell profile, which is ~/.bash_profile for the bash shell.

export MAVEN_HOME=/path/to/apache-maven-2.2.1

Now if you type the command mvn Maven should bootstrap itself.

Setup Maven On Windows

Download the Maven 2.2.1 zip file.

Unzip this file in the directory where you want to install Maven by moving the zip file there, right clicking on it, and selecting Extract Here.

The MAVEN_HOME variable needs to be set. Under the Start menu, open Control Panel under Settings. Now double click on the System icon. Go to the Advanced tab. Click Environment Variables. Under the System variables box click New. Now enter the path to maven by going to the directory in Explorer and copying it into the Variable value box. In the Variable name box type MAVEN_HOME. Click OK.

Add Maven's bin directory to the Path by find the variable called Path in the System variables box. Select this line and then click Edit. Hit the End key to go to the end of this variable. Type the ; character, which is the path separator, and then paste the value %MAVEN_HOME%\bin. Make sure not to overwrite the paths that are already there, or you could really mess up your system. Click OK.

Adding an environment variable on Windows

Read this support page if you are unsure how to add environment variables on Windows.

Click on Run in the Start menu. Open a command window by typing cmd in the box and hitting Enter. In the command window that pops up, type mvn and enter. Maven should bootstrap itself if you have setup everything correctly. If the command is not found, check that the Path variable contains %MAVEN_HOME%/bin.

Setup Netbeans

Go to Netbeans Downloads and get the Java version.

Run the installer.

Uncheck register and usage boxes.

In Netbeans, go to Tools > Options > Miscellaneous > Maven.

In the box that says External Maven Home, enter the path from the MAVEN_HOME variable.

Check the Skip Tests button.

Under Global Execution Options, put in -q to turn off verbose Maven output.

The option -o can be added when you are running without an internet connection.

Netbeans Settings

To fix running Maven TestCases in Netbeans, right-click on the project and go to Properties > Build. Click on Compile. Set Compile on Save to For application execution only.

Increase the VM heap size for the project by going to the project's Properties and under VM Options in Run, put in -Xmx1024m or however much memory is appropriate for your system. The default is usually -Xmx512, which may not be enough for running some tests.

  • No labels