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

Java项目IntelliJ配置命令行运行遇错:无法找到或加载主类.normalize

Fixing "Could not find or load main class .normalize" in IntelliJ for Your Java Project

Looks like the issue here is that you're mixing up the terminal script (./normalize) with the actual Java main class IntelliJ needs to target. Let's break this down and get your run configuration working step by step:

1. Find your real main class

The ./normalize command you use in the terminal is almost certainly a shell script (or executable wrapper) that runs a java command under the hood. You need to track down the full qualified name of the actual Java class with the public static void main(String[] args) method — this is your project's entry point:

  • Search your project codebase for classes containing the main method. It’ll look something like com.yourteam.normalize.Normalize (adjust the package path to match your project structure).
  • If you use Maven or Gradle:
    • For Maven, check plugins like maven-shade-plugin or spring-boot-maven-plugin — they usually explicitly define the main class in their configuration.
    • For Gradle, look for the application plugin’s mainClass property in your build file.

2. Configure IntelliJ's Run/Debug Configuration

Once you have the main class name, set up your run config properly:

  • Go to Run > Edit Configurations in the top menu bar.
  • Click the + icon in the top-left corner and select Application from the dropdown.
  • In the Main class field, paste the full qualified name of your main class (e.g., com.yourteam.normalize.Normalize — do NOT use ./normalize here, that’s the script name, not a valid class).
  • In the Program arguments field, paste exactly the parameters you use in the terminal:
    --manifest /MyUsrPath/myFile.csv --input /MyUsrPath/myOtherFile.csv
    
  • Ensure the Working directory matches the folder you’re in when running the script from the terminal (this is usually your project’s root folder).
  • Click Apply then OK to save the config.

3. Extra fixes if it still fails

  • If ./normalize has custom classpath settings or VM arguments, open the script file and look for lines starting with java. Copy any -cp/-classpath values into IntelliJ’s Classpath section, or any VM flags into the VM options field of your run config.
  • Run Build > Build Project to confirm all classes compile correctly — fix any compilation errors before trying to run again.

内容的提问来源于stack exchange,提问作者Marcus

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.22 09:58:24