IntelliJ Main Class Error

656 Views Asked by At

I am receiving an error that states that I need to specify a main class. As I am new to Java and IntelliJ I do not know what to specify. Here is an example that I am working on:

public class Grades
{
    public static void main(String[] args)
    {
        int grade1 = 95;     //first grade
        int grade2 = 88;     //second grade
        int grade3 = 76;     //third grade

        //calculate average
        int avgGrade = (grade1 + grade2 + grade3)/3;

        //print results
        System.out.print("Average = ");
        System.out.println(avgGrade);
    }//end of main method
}//end of class

I would appreciate any suggestions!

2

There are 2 best solutions below

2
On

A main class is one that contains an entry-point (in Java, that's your main method). So your main class is Grades.

0
On

Go to the Run menu, select Configurations, go to the Configuration tab and set the Main class field to Grades.