Logo

2 Application Class

At the beginning, we need to create a file that is to become the core of our module. Let's call it HelloWorldControllerImpl.java. As typical Java source file, it contains:

  • File Header Comment with: File Name, Copyright Statement, License, Project Reference
  • Package Definition
  • Import Statements
  • Class Header Comment with: Class Description, CVS version/date/author, Author Name and email Address
  • Class Definition
  • Attributes
  • Methods
Whenever you create new classes (files), just copy & paste some class from somewhere in the project, and then make necessary changes (put the correct year to the copyright, replace the author's name and email with yours and give the new class its correct name). At the beginning of the file and class header, one can find a statement enclosed in "$". This is just some additional information by which the Concurrent Versions System (CVS) is enabled to automatically keep track of source file changes.

The HelloWorldControllerImpl class inherits from the Object parent class - the top most class of the Java class hierarchy. It contains only one static (class) method main. Every class that shall be started from the system, must contain a main method.

A try-catch block encloses the code to catch eventual exceptions that may occur when running the system. System.out.println just prints out an information message on console. The statement that creates the actual instance of our class (the new module) is:

HelloWorldControllerImpl c = new HelloWorldControllerImpl();

That's it. When the program gets started on command line or per shell/batch script, you should see a message "Hello World!" on your screen. You can copy and adapt the build.sh/build.bat script and build.xml file in directory /bin/application/sample/helloworld/ to build the Hello World project. To run the project, use the start.sh/start.bat script.

To be honest, this program would also run without creating the instance (object) of HelloWorldControllerImpl. But for demonstration reasons and to prepare you for further steps, this line was already included here.

Here's a sample of how the program output should look like on console now:


Previous Contents Next


Copyright (c) 1999-2002. The Res Medicinae Webmasters. All rights reserved. GNU FDL license. Last Update: 06.05.2002