NoName
NoName

Reputation: 10334

Cannot Run Class Files

Notice that the run option for the main class is greyed out. I tried restarting intelliJ, rebuilding, cleaning, everything.

enter image description here (click to zoom in)

Upvotes: 0

Views: 3098

Answers (3)

Przemysław Moskal
Przemysław Moskal

Reputation: 3609

Correct your main() method, from:

public static void main() {...}

to

public static void main(String[] args) {...}

Upvotes: 1

Akshay Bahadur
Akshay Bahadur

Reputation: 517

Move your code inside of the src folder. Once it's there, it'll be compiled on-the-fly every time it's saved.

IntelliJ only recognizes files in specific locations as part of the project - namely, anything inside of a blue folder is specifically considered to be source code.

Also - while I can't see all of your source code - be sure that it's proper Java syntax, with a class declared the same as the file and that it has a main method (specifically public static void main(String[] args)). IntelliJ won't run code without a main method (rather, it can't - neither it nor Java would know where to start).

Use

public static void main(String[] args))

Upvotes: 2

Koekje
Koekje

Reputation: 777

Your main method requires a String array or varargs argument to be picked up.

Upvotes: 1

Related Questions