1
votes

I have installed Apache Maven following these steps.

  1. JDK and JAVA_HOME Make sure JDK is installed, and “JAVA_HOME” variable is added as Windows environment variable.

  2. Download Apache Maven Visit Maven official website, download the Maven zip file, for example : apache-maven-3.2.2-bin.zip. Unzip it to the folder you want to install Maven.

Assume you unzip to this folder – C:\Program Files\Apache\maven

  1. Add M2_HOME and MAVEN_HOME Add both M2_HOME and MAVEN_HOME variables in the Windows environment, and point it to your Maven folder.

M2_HOME or MAVEN_HOME Maven document said add M2_HOME only, but some programs still reference Maven folder with MAVEN_HOME, so, it’s safer to add both.

  1. Add To PATH Update PATH variable, append Maven bin folder – %M2_HOME%\bin, so that you can run the Maven’s command everywhere.

  2. Verification Done, to verify it, run mvn –version in the command prompt.

    Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-14T01:40:2
    7+05:30)
    Maven home: C:\Program Files\Apache Maven
    Java version: 1.8.0_40, vendor: Oracle Corporation
    Java home: C:\Program Files\Java\jdk1.8.0_40\jre
    Default locale: en_US, platform encoding: Cp1252
    OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
    

But When I build a project in Eclipse LUNA, I get this error.

Buildfile: C:\Users\Sarnath K Jegadeesan\Documents\BroadLeafQuillingArtWorkspace\DemoSite\site\build.xml
start-db:
     [echo] Starting Data Base...
jetty-demo:
[artifact:mvn] Listening for transport dt_socket at address: 8000
[artifact:mvn] -Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
[artifact:mvn] Java Result: 1
BUILD SUCCESSFUL
Total time: 5 seconds

I have all the environment variables properly set. How do I resolve this issue?

2
It does say build successful, what is the problem here?Dragondraikk
Did you reopen console after properties setting?Alexander Fedyukov
@Dragondraikk: See Last but 4th Line. -Dmaven.multiModuleProjectDirectory system property is not set.Sarnath Jegadeesan
@AlexanderFedyukov Yes. But I still have the issue.Sarnath Jegadeesan

2 Answers

1
votes

In your Eclipse IDE edit Installed JREs and add following property in Default VM arguments

-Dmaven.multiModuleProjectDirectory=$M2_HOME

Window-> Preference -> Java -> Installed JREs -> Edit enter image description here

Restart Eclipse and It will work fine :)

0
votes

First, you need to Locating the Environment Variables

1. Open up the system properties (WinKey + Pause) and you should see the below screen.

enter image description here

2. From the system properties, tab select the "Advanced" link. This should take you to the below screen.

enter image description here

3. From the System Properties screen select the "Advanced Tab". On this screen click the "Environment Variables" button.

4. You should now be seeing something like the below screen.

enter image description here

Now You Are Ready To Add Variables - Apache Maven

In the system variables section click on the "New" button.

In here enter the variable name : M2_HOME

Enter the variable value as the location of the Apache Maven installed in the previous section. (this is assuming you have already installed Maven into the desired folder if have not at this point do it now)

For an example of my location below. (Please note the variable value will vary depending on your install location and version of Apache Maven installed)

enter image description here

Click ok to complete this action. Once completed you should see the M2_HOME variable in the list of system variables.

Next due to an idiosyncrasy within eclipse (only if you are using eclipse) you need to create another new variable called M2 and point it at your newly created M2_HOME variable.

Example below:

enter image description here

Next, you need to add the newly created M2_HOME variable onto your path.

To do this locate the "Path" variable in the system variables list. Select it and click the edit button.

This should bring up the below option. (For Maven 2.0.9 or newer versions, also be sure that the M2_HOME doesn't have a '\' as the last character.)

Be sure to omit any quotation marks around the path even if it contains spaces.

enter image description here

Scroll to the end of the "variable value" and append on the following ;%M2_HOME%\bin

Click "OK" to confirm and leave the edit path screen.

Once complete click "OK" to confirm and leave the Environment variables screen.

Next, open a new command prompt (Winkey + R then type cmd) and run mvn -version to verify that it is correctly installed.

If it is you should see something similar to the below screenshot.

enter image description here

Optional: In the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value -Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.