NetBeans Project for Assignments Creating a NetBeans Project for Assignments Create a NetBeans project that will contain all of your homework projects for the rest of the course. Create a new Java Application. Be sure to uncheck Create main class. Right-click on the Source Packages folder and select New -> Java Package. Enter your webmail user name for the name of the project. Right-click the user name package and select New -> Java Main Class... Name your class Menu. Run the project. You will be prompted to select the main class. There will only be one choice: select it. From now on, you will use this project for all your homework assignments. You will just add more packages and main classes to this project. Chapter Package Add a package to the application. This package will contain several main classes: one for each part of the assignment. Right-click the user name package and select New -> Java Package. Set the name as username.chX (replace username with your webmail user name and X with the chapter number; for example, tdowne99.ch5). You will now have two packages in your application. Think of packages as subfolders. Right-click the username.chX package and select New -> Java Main Class.... Give the new class an appropriate name for the part of the assignment it implements, for example, Batting. Add a print statement in the main method that prints a simple message, like, "Batting Class". Calling the Batting Class from the Menu Class The Menu class is the main class for the entire application. It can access the Batting class that you just added. Open the Menu class and import the Batting class, for example import tdowne99.ch5.Batting. Add a print statement that prints that the Menu class is calling the Batting class. Call the main method of the Batting class from the main method of the Menu class. Run the program. You will see the following in the console window. run:
Menu calling the Batting class
Batting Class
BUILD SUCCESSFUL (total time: 0 seconds)
This was just an example of how to call one main class from another. For each chapter, you will add a new package, for example, tdowne99.ch6. For some chapters, you will define multiple main classes to implement each part of the assignment.