You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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\src is the main issue. This is Maven’s source code folder, not the root directory that contains critical folders like bin, conf, and lib—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:

  1. JAVA_HOME (this part is already correct, keep it as is):
    JAVA_HOME = C:\Program Files\Java\jdk-10
    
  2. 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:
    M2_HOME = C:\Users\Shrads\Softwares\apache-maven-3.5.3\apache-maven
    
    (If you extracted Maven directly into apache-maven-3.5.3 without an extra nested folder, use C:\Users\Shrads\Softwares\apache-maven-3.5.3 instead)
  3. PATH: Update the Maven entry to use the bin folder under your corrected M2_HOME path. Using the variable makes it more maintainable:
    PATH = C:\Program Files\Java\jdk-10\bin;%M2_HOME%\bin
    

How to apply the fix:

  1. Right-click This PC → select Properties → click Advanced system settings → open the Environment Variables window.
  2. Under either System Variables (for all users) or User Variables (just your account), find and edit M2_HOME, MAVEN_HOME, and PATH with the correct values above.
  3. Close all open Command Prompt windows—environment variable changes won’t take effect in already running terminals.
  4. Open a fresh Command Prompt and run mvn -version again. 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:58:29