error: Can not find or load the main class when compiling in CMD

advertisements

My code compiles when it is ran in Eclipse however whenever I try to run it in command prompt it throws the error "Could not find or load main class Menu" i've been stuck on this for hours and still have no idea how to fix it so any help would be massively appreciated. The switch statements call methods that are in different classes.

import java.util.Scanner;
import classSeperation.Frequency;
import classSeperation.InputFileAndString;

public class Menu {
public static String S="";
public static Scanner Scase = new Scanner(System.in);
//InputFileAndString inp= new InputFileAndString();
//Frequency FR= new Frequency();

public static void main(String[] args) {
    Menu mnu= new Menu();
    mnu.MainMenu();

}
    public void MainMenu(){
    System.out.println("Please enter a number");
    System.out.println("Enter 0 to exit the program");
    System.out.println("Enter 1 for inputting a file name");
    System.out.println("Enter 2 for inputting a string");
    System.out.println("Enter 3 for test 'I am a man frequency'");
    S= Scase.nextLine();
    Frequency FR= new Frequency();
    switch(S){
    default:
        System.out.println("Please select a valid option");
        MainMenu();
    case "0":
        System.out.println("Exiting program");
        System.exit(0);

    case "1":
        InputFileAndString inp= new InputFileAndString();
        inp.FileImp();

    case "2":

        FR.Freq();
        break;
    case "3":

        FR.ManFreq();
        break;
    }
    Scase.close();
    }

    public void SubMenuF(){
        System.out.println("Please enter a number");
        System.out.println("Enter 0 to exit");
        System.out.println("Enter 1 for a graph result");
        System.out.println("Enter 2 for character frequencies");
        System.out.println("Enter 3 to return to Main Menu");
        S= Scase.nextLine();
        Frequency FR= new Frequency();
        switch(S){
        default:
            System.out.println("This is not a valid option, please try again");
            SubMenuF();
        case "0":
            System.out.println("Exiting program");
            System.exit(0);

        case "1":
            FR.graph();
            break;
        case "2":
            //Frequency
            Frequency.frequencyFile();
            break;
        case "3":
            MainMenu();
        }
    }

    public void SubSubMenu(){
         String S="";
         Scanner Scase = new Scanner(System.in);
        System.out.println("Please enter a number");
        System.out.println("Enter 0 to exit the program");
        System.out.println("Enter 1 for a graph");
        System.out.println("Enter 2 to return to the main menu");
            S= Scase.nextLine();
        Frequency FR= new Frequency();
        switch(S){
        default:
            System.out.println("This is not a valid option, please try again");
            SubSubMenu();
            break;
        case "0":
            System.out.println("Exiting program");
            System.exit(0);
        case "1":
            FR.graph();
            break;
        case "2":
            MainMenu();
    }
        Scase.close();

    }

    }


Check if the file name is same as the class name... For example Menu.java

Is it an error while compiling or running?

What does "Could not find or load main class" mean?

this might help