简体   繁体   中英

Error: Could not find or load main class $MAVEN_HOME

while running maven clean I am getting the following error :

Error: Could not find or load main class $MAVEN_HOME

while doing mvn -version I got :

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:4
7+05:30)
**Maven home: D:\mavenSecurity\apache-maven-3.3.9\bin\..**
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_79\jre
Default locale: en_IN, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

I have set MAVEN_HOME = D:\\mavenSecurity\\apache-maven-3.3.9 in user variable in environment setting

Path in system variable in environment setting : D:\\mavenSecurity\\apache-maven-3.3.9\\bin

Since I am getting other error previously so I have done the following also as mentioned in this post:

Eclipse error setting up Maven project for class exercise: Check $M2_HOME environment variable and mvn script match

-Dmaven.multiModuleProjectDirectory=$MAVEN_HOME

I have consulted other links but still I am getting the error while running MAVEN CLEAN in eclipse juno

configuring Maven on Eclipse. you have to tell eclipse where Maven has been installed so that it can use the Maven installation to build our projects.

在此处输入图片说明

Win 7 64 . Here is how i did my config.

在此处输入图片说明

This worked for me with the 3.3.9 version. The only difference is :

1) Add both M2_HOME and MAVEN_HOME variables in the Windows environment, and point it to your Maven folder (Note: I have added it to system variables)

设置环境变量

2) Update PATH variable, append Maven bin folder – %M2_HOME%\\bin , so that you can run the Maven's command everywhere

Post output of mvn –version again if you face the issue. Also try running mvn clean from the command line and post the results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM