Search code examples
javaarraysobjectmethodsprogram-entry-point

Getting main method issue but main method is there?


So I have a program where it is saying that I need to add public static void mean to my case but it is already in the case so I'm not sure why I am unable to get any results. My code is showing no errors but once I run I get the same message. I have two public classes so I'm adding both so anyone can see the full programming. I have absolutely no idea how to get rid of this error.

Error: Main method not found in class finalproject, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application

public class finalproject {
    public static class employeeCase {
        //This main method doesn't work
        public static void main(String[] args) {
            System.out.println("Test");
        }
    }
}

Solution

  • The error is stating that you need a main method in the finalproject class. Once you have added that method then you can call any other method you want, which in your case would be employeeCase.main(args);:

    public class finalproject {
    
        //Add the below three lines:
        public static void main(String[] args) {
            employeeCase.main(args);
        }
    
        public static class employeeCase {
            ....