![]() |
Your First Java Application With VisualAge
In this Magercise, you will create a simple application that prints "Hello World!" to standard output. The tasks below walk you through the appropriate steps. Work LocationPerform all work for this magercise in VisualAge project MageLang Magercises, package magercises.helloapplication. If this project does not appear in your Workspace add it from the repository (if it exists there) or create a new project using this name. Tasks
Perform the following tasks:
![]() Create a new class in the HelloWorld project by clicking on the "create new class" icon (the icon under the menu bar that as the letter "C" on it). Type "HelloWorld" into the text field to the right of "Class Name". Click the "Next" button. VisualAge will warn you that no package exists for this class. Click "Continue" to force it to make a default package for you. The next dialog box asks questions about what classes and interfaces your new class will need. Simply click "Next". The final dialog box asks about what interfaces your new class will implement. Simply click "Finish" to create your new class. Your workbench will contain should the HelloWorld class in the HelloWorld project and should resemble:
![]() Create a main method by clicking on the "create method or constructor" icon under the menu bar (the icon has the letter "M"). From the drop down list, select "main Method". The dialog should look like:
![]() Click "Finish".
Instruct the main method to print "Hello World!" to standard out by
adding:
![]() Using the popup menu (right mouse click), select "Save", which instructs VisualAge to incorporate your changes. Select the HelloWorld class above the main method in the workbench upper pane (the class should have a very small icon representing a person running). Next, click on the larger icon of a person running underneath the toolbar to run your program. VisualAge gives you a dialog box asking for command-line parameters to pass to the application (these are analogous to argc and argv in C/C++). Click "Run". VisualAge will bring up the console and in the standard output pane, you should see the output "Hello World!".
|
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |