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-pluginorspring-boot-maven-plugin— they usually explicitly define the main class in their configuration. - For Gradle, look for the
applicationplugin’smainClassproperty in your build file.
- For Maven, check plugins like
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./normalizehere, 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
./normalizehas custom classpath settings or VM arguments, open the script file and look for lines starting withjava. Copy any-cp/-classpathvalues 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
相关产品推荐
相关产品推荐

