Popular Posts

Monday, February 23, 2009

Exercise 8.1: Building and running CommandLine sample program


Introduction:

In this exercise, you are going to build and run a sample Java program called CommandLineusing NetBeans. The sample program can be built and run as NetBeans project. So you are going to open an existing NetBeans project rather than creating a new project. (This is a similar setup as in Exercise 4.4 and Exercise 4.5 above.)

Steps to follow

0. If you have not downloaded and unzipped the NetBeansFiles.zip file as described above, please do that first.
1. Start NetBeans (if you have not done so.)
2. Open an existing CommandLine sample NetBeans project.

* Select File from menu bar.
* Select Open Project (Crtl+SHift+O).
* In the Open Project window, browse to C:\NetBeansFiles\Chapter 8\8.1 directory and select CommandLineProject.
* Click Open Project Folder button.
* Expand CommandLineProject project node.
* Expand Source Packages. (The Source Packages node contains all the packages.)
* Expand . (If you create Java code without a package statement, it belongs to a default package.)
* Double click CommandLine.java to open it in the Editor window.

3. Add command line arguments

* Right click CommandLineProject project node and select Properties. Project Properties dialog box appears.
* In the Project Properties dialog box,
o Select Run under Categories pane on the left
o In the Arguemtns: field, type in 5 4 3 2 1
o Click OK.
4. Run the program.

* Right-click CommandLineProject project node and then select Run Project.
* You should see the numbers 5, 4, 3, 2, 1 are displayed in the Output window of NetBeans.

No comments:

Post a Comment