IntelliJ unable to run: main class not found. Terminal runs the class just fine

Sam

After extensive research through Google, Stackoverflow and peers I am still unable to solve the below stated issue.

IntelliJ is unable to locate any main class of whatever file I choose:

Error: Could not find or load main class nl.sam.inventory.InventoryApplication

I have followed the answer which was posted on SO: Error "ClassNotFoundException" in IntelliJ IDEA

My main class:

package nl.sam.inventory;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class InventoryApplication {

    public static void main(String[] args) {
        SpringApplication.run(InventoryApplication.class, args);
    }
}

My run settings are left as default (IntelliJ picked these up).

My project structure: Project Structure

If I left anything out please state so.

I have verified I have a JRE (11) and JDK (11) installed and working on my machine. In a terminal the program runs just fine: in IntelliJ I get the aforementioned error.

Edit: I use Maven for project management. A project without maven shows the same behaviour.

Sam

This issue was caused by something not yet described before. My path had a space in it, which my MacBook turned into a :. Due to this the main class could never be found. I've changed my username to not contain a space, and it now works just fine.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Cannot run Main class in Intellij

Java class runs fine in IntelliJ but not from command line

Maven error "Unable to initialize main class" when I try to run a jar file I just created

Unable to find or load Main Class in Intellij 2019.4

cannot select main class in intellij run config

JavaFX application runs fine when running Main in IntelliJ, built jar doesn't run

Is it fine to put a class inside the main class in Java?

No Main class found in NetBeans

Haxe - Class not found : Main

No main class found

Class file not found in IntelliJ

How run main class or tests in IntelliJ IDEA 2018.2.1 (Ultimate Edition)

Jenkins - bash: aws: command not found but runs fine from terminal

Can't choose class as main class in IntelliJ

Java Jar file main class run when runs from command line, but not from Windows batch file

Main method not found in scanner class

Main class could not be found and more

Error :: Main method not found in class

libgdx - Intellij class not found exception?

Heroku Unable to Find Main Class

run main class of Maven project

Project doesnt run main class

right click "run-ing" in intellij runs TestNG not main

IntelliJ IDEA does not run class

Unable to Run application via Terminal but application working fine in XCode

Spring Azure Function - Unable to load Main Class when running from IntelliJ Azure Toolkit

Could not find or load main class osx terminal

Could not find or load main class while trying to run project from IntelliJ

IntelliJ Idea: How to run Spring Boot application which has a main class in the external dependency?