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 Location

Perform 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:

  1. Create a new project by clicking on the "create new project" icon that looks like a little folder (the 7th icon from the left under the VisualAge for Java menu bar):
    Type "Your First Java Application with VisualAge" into the text field to the right of the radio button that says "Create a new project named:". Push the "Finish" button in the lower right corner of the dialog box. VisualAge will return you to the workbench after it has completed creating your package. You should see it listed with the other projects.

  2. 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:

  3. 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".

  4. Instruct the main method to print "Hello World!" to standard out by adding:
    System.out.println("Hello World!");
    
    after the "{", but before the return statement. Your workbench should look like the following:

    Using the popup menu (right mouse click), select "Save", which instructs VisualAge to incorporate your changes.

  5. 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!".

The task numbers above are linked to the step-by-step help page. Also available is a complete solution to the problem, and expected behavior, to demonstrate it.

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.