Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

Hello World The Application in NetBeans 4 by pzk16293

VIEWS: 7 PAGES: 14

									                   Hello World: The Application in NetBeans 4.1


If the NetBeans 4.1 application along with the Java 5 is installed on your computer,
then the NetBeans 4.1 icon should appear on the computer desktop. Start the
NetBeans 4.1 IDE application by double clicking the NetBeans 4.1 icon on your
desktop. If you do not maintain the icon on your computer desk top you should be
able to launch (run) the NetBeans 4.1 IDE from the Windows Start -> Programs ->
NetBeans 4.1.

This document contains one of the simpler ways that a programmer can create a
new programming project using NetBeans and Java.




                            The NetBeans Icon




NetBeans Icon on Desk Top




Charlie Martínez                         UMUC Asia                         Page 1 of 14
                   Hello World: The Application in NetBeans 4.1


Let‟s begin by Opening a New Project area where we can create a Java application in
NetBeans.

Select File -> Open Project




                    Open Project




Open Project




Charlie Martínez                     UMUC Asia                            Page 2 of 14
                     Hello World: The Application in NetBeans 4.1


This window should pop-up. This is how we tell NetBeans what we plan to do.

For now, insure that:

             1. In the Categories window, the folder „General‟ is highlighted.
             2. In the Projects window, „Java Application’ is highlighted.
             3. Finally, single click the „Next >’ button




                   1.) General                  2.) Java Application




                                       3.) Next >




What type of Project?




Charlie Martínez                          UMUC Asia                              Page 3 of 14
                          Hello World: The Application in NetBeans 4.1


       The next window dialog to pop-up requests some information from you.

           1. The „Project Name’: Enter the name of this project “HelloWorldAgain”
                    a. Use the provided „Project Location’ and ‘Project Folder’ for now.
           2. Insure that the two check boxes, labeled ‘Set as Main Project’ and ‘Create Main
                Class’ have a check mark.
           3. Finally, click the Finish button.




     1.) Project Name



2.) The Check Boxes




                           3.) Finish




       Give the Project a name.




       Charlie Martínez                           UMUC Asia                            Page 4 of 14
                         Hello World: The Application in NetBeans 4.1




      The HelloWorldAgain project should now be displayed in the Project window and
      Main.java opens in the Source editor.

      Notice the source code file already has some of the preliminary work done for you.
      This is the window that has the tab Main.java.

      Take some time to review the contents of the windows so you learn what to expect
      when you create your own applications.

      NetBeans tries to help you out by providing a common template when the .java file
      is opened for the first time. Look thru what is given to you by NetBeans as there are
      additional lines of code, required by NetBeans, that are not presented in the
      textbook.


                                                           This is the Java
                                                           source code window




This is the Project
window




                 TODO… line of
                 source code.




      NetBeans Auto Gen



      Charlie Martínez                        UMUC Asia                           Page 5 of 14
                   Hello World: The Application in NetBeans 4.1




Where you see this line of comment     // TODO code application logic here

replace it with… System.out.println(“Hello World Again”);

Notice the IDE(Integrated Development Area) tries to help you by including both
sets of double quotes “ “ for you. Be careful that you get only one set of double quotes.

Did you include the „;‟ semicolons?

Do you still have all of the „{“open and „}‟close braces? There should be four of them.

Does every open parenthesis have matching close parentheses?




                                                                Hello
                                                                World
                                                                Again




Type in 'Hello World Again'




Charlie Martínez                       UMUC Asia                               Page 6 of 14
                   Hello World: The Application in NetBeans 4.1


The next step is to „compile‟ your program. One way to compile a program with
NetBeans is to Single click the „Build Main Project’ icon on the menu bar.

If you have errors, the NetBeans IDE tries to help you out some. The error listing is
in the bottom window labeled Output – Helloworldagain(jar).




                                       Build
                                       Main
                                       Project




                                Report
                                from the
                                compile,
                                if exist.




Build Main Project.




Charlie Martínez                        UMUC Asia                            Page 7 of 14
                   Hello World: The Application in NetBeans 4.1




Now let‟s see if the Java program works. Click the „Run Main Project’ icon on the
menu bar.




                      Run
                      Main
                      Project




Execute the Application




Charlie Martínez                      UMUC Asia                             Page 8 of 14
                   Hello World: The Application in NetBeans 4.1




To see the output of this Java program, look in the bottom window again.




                                                 Results




The Results




Charlie Martínez                     UMUC Asia                             Page 9 of 14
                   Hello World: The Application in NetBeans 4.1




The NetBeans application does several other things for you behind the scenes while
you were working on the source code.

Look over in the Projects window and browse through the various files that were
created.




                                 The Projects Window.




Various Types of Files Created




Charlie Martínez                          UMUC Asia                      Page 10 of 14
                      Hello World: The Application in NetBeans 4.1




Once you‟re done,

    1. close the project: from the main menu select File -> Close “HellowWorldAgain”
    2. exit NetBeans selecting File -> Exit.




                                        1.) Close “HelloWorldAgain”




                             2.) Exit




Close the Project 1




Charlie Martínez                                UMUC Asia                  Page 11 of 14
                   Hello World: The Application in NetBeans 4.1




To re-open a Project, follow the menu to your project and navigate File -> Open
Recent Project -> Project Name.




                          To open a
                          project that
                          has been
                          closed.




Open a Previous Project




Charlie Martínez                         UMUC Asia                         Page 12 of 14
                   Hello World: The Application in NetBeans 4.1




A file view of the Java source and class that were created using Windows
Explore.




Windows Explore View 1




Windows Explore View 2




Charlie Martínez                     UMUC Asia                     Page 13 of 14
                   Hello World: The Application in NetBeans 4.1




Windows Explore View 3




Charlie Martínez                     UMUC Asia                    Page 14 of 14

								
To top