Main class not found in project IntelliJ IDEA: Java Application

IntelliJ does not find a main class in my Java application project. The project was cloned from a git repository so had no run configuration. I go to Edit Configurations, add a new Application template, go to Main class: and it says "No matches found in project".

So, manually searching through the hierarchy I find the .java file that contains the main function but it will not accept it as the main class. I've pasted the file below to prove that it has the correct main function.

public class AdvanceWarsGameHandler implements IGame
{
private Image mImage;
private String mTitle;

public AdvanceWarsGameHandler()
{
    mTitle = "Advance Wars Game";
    mImage = new Image("/OffBrandCerealOopsAllCarries2-01.png");
}

//Game logic unrelated to graphics goes here
@Override
public void update(Game game, float deltaTime) 
{

}

//Update, but for graphics
@Override
public void render(Game game, Renderer renderer) 
{
    renderer.drawImage(mImage, game.getInput().getMouseX(), game.getInput().getMouseY());
}

 public static void main(final String args[])
{
    //Creating and starting an instance of AdvanceWarsGameHandler
    AdvanceWarsGameHandler advancewars = new AdvanceWarsGameHandler();
    Game myGame = new Game(advancewars);
    myGame.start();
}

public String getTitle()
{
    return mTitle;
}

}

So the question is, why is the IntelliJ project not recognizing the main function in this file, or what is IntelliJ looking for as the “Main class” of an application?

#java #intellij-idea

4 Likes190.20 GEEK