Windows 8.1系统下Apache Maven 3.5.3安装启动异常求助
Fixing Maven "Error: -classpath requires class path specification" Issue
Hey there, let's get your Maven setup working smoothly! The error you're hitting comes down to incorrect environment variable configurations—you’ve pointed M2_HOME and MAVEN_HOME to the src folder instead of Maven’s actual installation root, which breaks the classpath setup.
What’s wrong with your current config:
- M2_HOME/MAVEN_HOME: Setting these to
C:\Users\Shrads\Softwares\apache-maven-3.5.3\apache-maven\srcis the main issue. This is Maven’s source code folder, not the root directory that contains critical folders likebin,conf, andlib—Maven needs access to those to run properly. - PATH: Your Maven bin path points to
src\bin, which doesn’t hold the valid execution scripts needed to launch Maven correctly.
Correct Environment Variable Configurations:
Let’s update these values step by step:
- JAVA_HOME (this part is already correct, keep it as is):
JAVA_HOME = C:\Program Files\Java\jdk-10 - M2_HOME and MAVEN_HOME: Set both to the root folder of your Maven installation (the one that directly contains
bin,conf, etc.). For example:
(If you extracted Maven directly intoM2_HOME = C:\Users\Shrads\Softwares\apache-maven-3.5.3\apache-mavenapache-maven-3.5.3without an extra nested folder, useC:\Users\Shrads\Softwares\apache-maven-3.5.3instead) - PATH: Update the Maven entry to use the
binfolder under your correctedM2_HOMEpath. Using the variable makes it more maintainable:PATH = C:\Program Files\Java\jdk-10\bin;%M2_HOME%\bin
How to apply the fix:
- Right-click This PC → select Properties → click Advanced system settings → open the Environment Variables window.
- Under either System Variables (for all users) or User Variables (just your account), find and edit
M2_HOME,MAVEN_HOME, andPATHwith the correct values above. - Close all open Command Prompt windows—environment variable changes won’t take effect in already running terminals.
- Open a fresh Command Prompt and run
mvn -versionagain. You should now see your Maven version, JDK details, and confirm everything is working as expected.
The error popped up because Maven couldn’t locate its core libraries and execution scripts when pointed to the src folder. By fixing the paths to target the actual installation root, the classpath gets configured properly, and the command will run without issues.
内容的提问来源于stack exchange,提问作者Shrads
相关产品推荐
相关产品推荐

