Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

Hello World (updated): Rational Application Developer V7

Create Java, Web service, and database applications

Jane Fung (mailto:jcyfung@ca.ibm.com), Software Developer, IBM Toronto Lab
Jane Fung works on the WebSphere Studio Application Developer Integration Edition tools team. Jane earned a Bachelor of Applied Science degree in Electrical Engineering at the University of Waterloo, Ontario, and is a Sun Java 2 Certified Programmer. You can reach Jane at jcyfung@ca.ibm.com .

Summary:  Try some practical exercises that show how to create a Java™ application, create and invoke a Web service, and create a Web application that can access a Derby database using a Relational Record List. Learn about J2EE application development using IBM Rational Application Developer. The original version of this tutorial for Rational Application Developer V6 is still available.

View more content in this series

Date:  23 Jan 2007
Level:  Introductory PDF:  A4 and Letter (1363 KB | 37 pages)Get Adobe® Reader®

Activity:  50505 views
Comments:  

Creating a Java application

To create a Java application that prints the line Hello, World!:

  1. Start Application Developer, if you haven't already done so. From the Windows Start menu select Programs > IBM Software Development Platform > IBM Rational Application Developer > IBM Rational Application Developer.
  2. A window displays and requests the workspace directory. Click OK to accept the default.

Creating a new Java project

Create a Java project named MyJavaProject, which has source and binary folders to store the Java and class files, respectively.

Would you like to see these steps demonstrated for you?

Show me Show me

  1. From the workbench, select File > New > Project.
  2. Select Java > Java Project > Next. If you do not see Java, select the Show All Wizards check box. Select OK if you are prompted about enabling Java development capability.
  3. Enter MyJavaProject as the project name.
  4. Select the Create separate source and output folders option and click Finish.
  5. Click Yes if you are asked to change to the Java Perspective.


    Figure 4. New Java Project window
    Figure 4: New Java Project window


Creating a new Java class

Create a Java class named Test inside a test package, as shown in Figure 5.

  1. In the Package Explorer view, right-click MyJavaProject and click New > Class.
  2. Enter test as the package and Test as the file name.
  3. Make sure public static void main (String[] args) is checked.
  4. Click Finish and the Java editor opens.


    Figure 5. A new Java class
    Figure 5: A new Java class


Modifying the Java class

  1. In the Java editor, modify the Java class as Listing 1 shows in bold.

    Listing 1. Code for the test.Test class
                                
    public class Test {
    
    	public static void main(String[] args) { 
    		System.out.println ("Hello, World!!");
                                System.out.println ("Hello, World Again!!"); 
    	} 
    }
    

    As you type, you can use the Code Assist (Ctrl-Space) function to help you complete the keywords.

  2. Save the file by pressing Ctrl-S.

Running the Java application

Now it's time to run your first application.

  1. In the Package Explorer view, right-click the Test class and click Run > Java Application, as shown in Figure 6.


    Figure 6. Running a Java application
    Figure 6: Running a Java application.

  2. Switch to the Console view to see the result of the application, shown in Figure 7. If the Console view is not visible, you can switch to it by going to the Windows menus > Show View > Console.


    Figure 7. The Console view
    Figure 7: The Console view.

    The output for running your Java application is displayed in the console. You see the two lines of text that were printed from the Java application.

4 of 9 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational, Java technology
ArticleID=188449
TutorialTitle=Hello World (updated): Rational Application Developer V7
publish-date=01232007
author1-email=mailto:jcyfung@ca.ibm.com
author1-email-cc=