Skip to content

How to Fix IntelliJ Run Configuration Errors — Application Not Starting

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix IntelliJ Run Configuration Errors. We cover key concepts, practical examples, and best practices.

The Problem

IntelliJ cannot run your application:

Error: Could not find or load main class com.example.Main

or:

Module not specified

Quick Fix

Step 1: Check the run configuration

Run > Edit Configurations

Verify:

  • Main class: Fully qualified class name with main() method
  • Module: The correct module is selected
  • JRE: The correct JDK is selected

Step 2: Add a missing main class

If the dropdown is empty, browse and select the class:

Edit Configurations > Main class > ... (browse) > Select main class

Step 3: Fix the module setting

Edit Configurations > Use classpath of module > Select your module

If no modules appear:

File > Project Structure > Modules > + > Import Module

Step 4: Set program arguments

Edit Configurations > Program arguments

Example: --port=8080 --debug

Step 5: Add environment variables

Edit Configurations > Environment variables

Example: DATABASE_URL=jdbc:<a href="/databases/postgresql/">postgresql</a>://localhost:5432/mydb;DEBUG=true

Step 6: Rebuild before running

Build > Build Project

Then try running again.

Prevention

  • Use the class browser (the ... button) instead of typing the class name.
  • Use template-based configurations for consistency.
  • Share run configurations via .run/ directory in version control.

Common Mistakes with run config

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

These mistakes appear frequently in real-world INTELLIJ code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does IntelliJ say "Module not specified"?

The project structure is not properly configured. Open File > Project Structure > Modules and ensure your source root is marked as Sources.

How do I pass command-line arguments to a Java application in IntelliJ?

Edit the run configuration and add arguments in the Program arguments field. Separate multiple arguments with spaces.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro