UNF COP 3540 - Using NetBeans to Create and Run a Java Application

Unformatted text preview:

Using NetBeans to Create and Run a Java ApplicationNetBeans is an open source IDE (integrated developmentenvironment) available to programmers who want to develop Javaprojects. Since it is an IDE, the tools needed for editing, compiling,building, debugging, executing, and obtaining online help are allintegrated in one graphical user interface. Using these tools effectivelycan greatly increase your productivity. 1. Start NetBeans by selecting NetBeans IDE 4.1 from the Startmenu or by double-clicking the desktop shortcut. If the Welcomewindow appears, close it by clicking on the “x” just to the right of“Welcome” on the Welcome tab. You may also close the Navigator window by clicking on the “X” to thefar right of its title bar. You should now be observing only the Projects,Files, and Runtime window title bars on the left hand side of the mainworkspace window and a blank, empty panel on the right. (If for somereason they are not, or have been closed accidentally, you can selectthe Window menu and select the Projects choice, File choice, or theRuntime choice to get them back.12. Project Window: In the screen shot below, the Projectwindow is open showing that NetBeans was previously used tocreate several earlier Java projects (Lab0Project, Lab1Project, andLab2Project). Your window should be empty at this point. To switch between the Project, Files, or Runtime windows simply clickon the desired window’s title bar.) Select the Project’s window if it is not currentlyselected. Before starting, you should create a folder on your desktop entitledCOP3540. Each lab project this semester will be entitled,projectiyouruserid, where i is the number of the project. Eachproject you develop will be located in a different folder withinCOP3540.1 To continue working on a project that was begun earlier,simple click on the desired project in the Project window andcontinue development. You must also ensure that the project youare working on is the Main Project, and there can be only one Mainproject.3. New Application: To create and run a new Java applicationyou must first create a project. In the following exercise we will becreating a project named projectiyouruserid.1 a. Choose New Project… from the File menu. The screen belowshould appear. (You may have to select the figure and zoom in to more clearly see thetext below.) 1 From the “General” category, select the “Java Application” choice and press the 2 Next> button. 34 (If you wanted to develop Applets, you would select Java Class Library)(Also: select some of the other options and note the Descriptionsbelow.)1 b. In the next window, 2 (i) Choose an appropriate project name in the style, projectiyouruserid3 (in this case I selected project2broggio).45 (ii) Please note that if you deselect the Create Main Class, you will get no 6 text displayed in the template shown below. I recommend that you do not7 uncheck this box.(iii) You may have also noticed that as you keyed in the project, the project location and project folder were simultaneously filled in by NetBeans.You should see: And when you depress the Finish button, you will see the provided template to support Java application development.Note the contents of all windows. Observe the Main.java tab. See the package id, the public class Main, the public Main() constructor, and the main() method.Note: You may wish to take time out and access your COP3540 folder on your desktop. You will note that a subfolder entitled project2broggio (or projectiyouruserid in general) will appear. There will also be a number of additional folders. We will discuss these at a much later date.At this time, you are ready to use the IDE to develop your Java application. Note: I strongly recommend that you take a few minutes and add scope terminators to the closing braces on each method and class. See Standards documented on my web page.4. Building the Source Code: Project0 Goes Right Here:The purpose of Project0 is to familiarize the student with the procedurein using NetBeans IDE and submitting a job to the instructor in proper format for grading. The value of Project0 is twenty points and you should get the entire 20 points if you follow the procedure outlined below. Note: This is the time to play with NetBeans to not only submit the required project assignment, but to experiment and play around with the very powerful IDE. The on-line tutorial isexcellent. Take time to learn a few other neat things. Perhaps you may wish to develop an applet or two.From my web page, you will note that there are a number of programs that were made available from the author of the book. The first program comes from Chapter 1 in your text and is called BankApp.javaYou will note that the file has two classes in it: class BankAccount and class BankApp. (Code is included below)Note that the first class, class BankAccount has a Constructor, while the second class, BankApp does not, although the public static void main() method lies here. But note that the IDE template does offer a Constructor for class Main, as it should. You may ignore or delete the main Constructor from the template if you wish once we enter this code into the code window..Note also that the template is set up for Javadoc. You are to use the Javadoc facility and generate your application’s Javadoc throughout this course. All projects, classes, and methods are to be fully documented. Once you enter and fully document your program, you may get NetBeans to automatically generate the Javadoc for you (under Build in the main NetBeans menu bar, select Generate Javadoc)From the BankApp file, copy the class BankAccount and add it carefullyinto the NetBeans template. Then, copy the main() method from classBankApp and insert it also into the NetBeans template. Add comments as appropriate into the comment entries set up for you via the IDE. Be certain to do this. It is an essential good habit.4.1 Going through the creation of project0broggio, as described above, we arrive at the template supplied by the IDE as shown above.4.2 File BankApp from my web page is:// bank.java////////////////////////////////////////////////////////////////class BankAccount { private double


View Full Document

UNF COP 3540 - Using NetBeans to Create and Run a Java Application

Download Using NetBeans to Create and Run a Java Application
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Using NetBeans to Create and Run a Java Application and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Using NetBeans to Create and Run a Java Application 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?