The Programming Activity examples from the book require you to edit the files that are provided in the exercise. In order to do that in NetBeans, it is necessary to create the project from exisitng sources.
Select File -> New Project from the main menu. Choose the Java category and the Java Project with Existing Sources project type.
Select Next. Enter the name for the project. I suggest that you include the word project in the name. For instance, if this is Activity One, then name the project ActivityOneProject.
Select Next. Browse to the folder that contains the source files. Do not open the folder, just select it.
Click Open; you will be returned to the wizard.
Select Next. You will see the list of files that are to be added. You only have to click Finish on this page, but take a moment to see if the correct files are being added.
Click Finish. You will be returned to the NetBeans window. You should see the files that have been added to your project. In this example, three files have been added to the default package. For now, all files will be in the default package. Later in the course you will learn how to use packages to organize your source code.
Double-click the SimpleDateClient file. It will open in the editor pane. There is also a list of methods for this class shown in the class Navigator pane. If you do not see the Navigator pane, then select the Window menu and select the Navigating sub menu; clicking on Navigator will toggle the visiblity of the Navigator pane. There are many other windows that can be toggled from this same menu.
Double-click the workWithDates method in the Navigator pane; you will see that the editor pane is scrolled to that method.
This is where you will make changes to the file. Once you have made changes, open the Run menu.
The project does not know which file contains the main method that starts the application, so it gives you a list of all the files that contain a main method. In this example, there is only one file with a main method. Select that file and click OK.
The application starts to run. The Activity One application animates the creation of objects by popping up a GUI frame. You will learn how to create such frames, later in the course.
Noitce that while the application is running, there is a progress bar displayed in the lower right area of the NetBeans window. If your application should end abnormally, this progress bar will still be there; click the x to stop the application.
When you submit an assignment, I want you to submit a JAR file. A JAR file is a ZIP file that contains all the files that are needed to run a Java application.
By default, the .java files are not included in the JAR file. I need the .java files in order to grade your assignment; so, you must modify how the project generates the JAR file. Right-click on the name of the project in the Project tab of NetBeans.
Select Properties.
Select Packaging. Remvove everything from the Exclude From JAR File box.
Click OK.
When your application is complete and ready to be submitted, run the Clean and Build command from the Build menu.
This will create the JAR file that contains all the source files that are in the application.
Using your operating system file browser, locate this JAR file. It will be in the dist subfolder of your project directory.
When you submit your assignment, submit this JAR file.
The JAR file is only created and recreated when Clean and Build is done, so always do this as a final step before you submit an assignment.
If you examine the Run and Build menus, you will see that some of the menu options have icons next to them. Some of these icons are added to the NetBeans toolbar. These provide you with a shortcut for executing these menu options.