Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Main method not found" error when starting program?
    primarykey
    data
    text
    <p>I'm learning Java for my course and I've hit a brick wall. I've been tasked with developing a simple command line program. To make things easier I was given the following sample code to modify so I wouldn't have to start from scratch.</p> <pre><code>package assignment; public class Main { private final static String[] mainMenuOpts = {"Students","Lecturers","Admin","Exit"}; private final static String[] studentMenuOpts = {"Add Student","List all Students","Find a Student","Return to Main Menu"}; private Menu mainMenu = new Menu("MAIN MENU",mainMenuOpts); private Menu studentMenu = new Menu("STUDENT MENU",studentMenuOpts); private DataStore data = new DataStore(); private java.io.PrintStream out = System.out; private ReadKb reader = new ReadKb(); /** Creates a new instance of Main */ public Main() { run(); } private void run(){ int ret = mainMenu.display(); while(true){ switch(ret){ case 1: students();break; case 2: lecturers(); break; case 3: admin(); break; case 4: exit(); break; } ret = mainMenu.display(); } } private void students(){ int ret = studentMenu.display(); while(ret != 4){ switch(ret){ case 1: addStudent();break; case 2: listStudents(); break; case 3: findStudent(); break; } ret = studentMenu.display(); } } private void lecturers(){ out.println("\nLecturers not yet implemented"); } private void admin(){ out.println("\nAdmin not yet implemented"); } //Student methods private void addStudent(){ out.println("\n\tAdd New Student"); //prompt for details //add student to the datastore //ask if they want to enter another student - // if so call addStudent again //otherwise the method completes and the studentMenu will display again } private void listStudents(){ out.println("\n\tStudent Listing"); //list all students from the datastore } private void findStudent(){ out.println("\n\tFind Student"); out.print("Enter Search String: "); //reasd search text //use datastore method to get list of students that contain the search string //display matching students } // end Student methods private void exit() { data.save(); //call the datastore method that will save to file out.println("\n\nGoodbye :)"); System.exit(0); } } </code></pre> <p>I'm using NetBeans and when I try to run the project I get this error:</p> <pre><code>Error: Main method not found in class assignment.Main, please define the main method as: public static void main(String[] args) </code></pre> <p>I just want to get the program running so I can understand the code better. I understand the error, but have no idea where to implement the main method in this wall of text. I've been experimenting for hours, but obviously as a newbie I'm completely useless. Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload