IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
      
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks > Linux >
developerWorks
Speed-start your Linux app 2003: "Hello, World" in 90 seconds with WebSphere Studio Site Developer V5
e-mail it!
Contents:
Introduction
Two minutes or less to a "Hello, World" application
Want more speed?
Summary
Resources
About the authors
Rate this article
Related content:
Speed-start your Linux app: Overview, training, tech support
WebSphere Studio Trial Program
WebSphere Studio Zone
Subscriptions:
dW newsletters
dW Subscription
(CDs and downloads)
Create and test a simple Linux app

Level: Introductory

Tom Mitchell (tommitch@us.ibm.com), WebSphere Technical Sales Support Team, IBM
Ian Shields (ishields@us.ibm.com), Senior programmer, IBM

01 Jan 2002
Updated 25 Mar 2003

This article shows you how to create and test a "Hello, World" application using WebSphere Studio Site Developer in a Linux environment, and then shows you how to add a "scrap page" for testing snippets of Java code. This article was originally published in January 2002 using examples from a Windows environment. Tom Mitchell developed the original article, and Ian Shields added the Linux updates for WebSphere Studio Site Developer V5 that you see here.

Introduction
When evaluating development tools, it is common to focus on features that simplify, accelerate, or make practical the development of complex applications. One of the underlying fundamentals of all IBM tools is the promise of making development of complex components easier and faster. WebSphere® Studio Site Developer (Site Developer) has a rich set of features that deliver on this promise. These features greatly simplify and accelerate the process of developing, testing, and deploying complex J2EE applications containing HTML, JSPs™, Servlets, Java™ beans, and other components.

Development tools should take into account the fact that many of the day-to-day tasks that a developer performs are fairly simple and narrow in scope. A good tool must allow simple tasks to remain simple. Frequently, Java developers create a small application to test or experiment with a simple Java feature. In these cases, development tools should help the developer to quickly create, build, and test the application. They shouldn't require the developer to navigate through or even be aware of the more advanced features and project structuring that would be needed to create large, complex J2EE applications.

One of the first things I do when evaluating a new tool is to create the classic (or cliché, depending on your opinion) "Hello, World" application. Once that works, I feel I have a solid base from which I can experiment with the other features. Ideally, I like to be able to perform this task without any product education. In fact, I've been known to skip the product documentation altogether. I imagine there are a few other "try it first, read the documentation later" types out there as well. As you will see, the "Hello, World" exercise is very easy and intuitive with Site Developer.

The rest of this article shows you how to create and test a "Hello, World" application, and then shows you how easy it is to add a "scrap page" for testing snippets of Java code. Site Developer is well suited to both simple and complex development tasks.

Two minutes or less to a "Hello, World" application
The steps below assume you are using the 60-day trial edition of Site Developer.

Let's review the user interface first. Site Developer is a task-oriented tool whose user interfaces are customized for the task being performed. The interface used for developing a JSP is much different from the one for Server development. Application Developer lets you control what windows and views you see by switching the perspective you are using. A perspective is a set of views that show the resources you need when performing a specific task. Site Developer has perspectives defined for Web application development, J2EE development, debugging, and many other common tasks. The left navigation bar contains icons that allow you to easily switch between perspectives. We will skip the Welcome panel that tells us how to use the IDE as we can always come back to it later using Help=>Welcome.

  1. Start Site Developer and open a Java perspective. To open Site Developer, run /usr/bin/wssitedev50 from a terminal window or just wssitedev50 if /usr/bin is in your path as it usually is. You can also do this from the taskbar on your desktop. For example, with KDE select Start Application=>Run Command... and type in wssitedev50 or /usr/bin/wssitedev50 as appropriate. Next, select Window=>Open perspective => Java from the main menu.

    Figure 1. Opening a Java perspective
    Figure 1

  2. Alternatively, you can click the Open Perspective button and select Java from the submenu.

    Figure 2. Using the Open Perspective tool

  3. Next, create a new Java project. Select File => New => Project or use the New Wizard button at the left end of the toolbar above the Open Perspective button. On the New Project dialog, select Java in the left column and Java Project in the right column.

    Figure 3. Creating a new Java project

  4. Click Next and enter the project name Hello in the project name field. Then click Finish to create the project.
  5. Now you will see the Hello project in the Packages view.

    Figure 4. The Hello project in the Packages view

  6. Add the Hello class. To do this, right-click on the Hello package and select New => Class, or simply click on the New Class button in the toolbar while the Hello package is selected.

    Figure 5. Creating a new class

  7. Type Hello in the name field and check the option to create a public static void main(String[] args) method.

    Figure 6. Creating the Hello class

  8. Click Finish and the main window should look this:

    Figure 7. The Hello class

  9. You could now run the application, but it wouldn't do anything, so we'll add one line of code to the main method. After the left brace ({), add System.out.println("Hello, World");
  10. You can add code like this more quickly by using code-assist. After you've typed System, key Ctrl-space, and a code-completion dialog will present valid object/method names. Code-assist reduces both keystrokes and errors significantly.

    Figure 8. Using code-assist to add code

  11. Type Ctrl-S (or use File=>Save) to save and compile the Hello class.
  12. Click the Run button to start the application . If this is the first time you've done this, a dialog will ask how the application should be launched. Select Java Application and click New.

    Figure 9. Creating a configuration

  13. On the next screen you can specify arguments for your application and additional information such as the JRE to use. For now, just click Apply and then click Run.

    Figure 10. Specifying configuration details

  14. Your application will run, and you will see your output in the console window:

    Figure 11. Running the application

  15. As you can see, Site Developer helps you get started quickly and simply. I timed myself when verifying the steps and it took 71 seconds.
  16. While it's unlikely that you'd need a debugger to follow the flow of this application, it's very easy to add breakpoints and debug. To set a breakpoint, right-click in the gray bar to the left of a line of code and select Add Breakpoint. Once you've set a breakpoint, a green circle appears in the gray bar to the left of the line of code.

    Figure 12. Setting a breakpoint

  17. To debug, click the Debug button, not the Run button. Clicking Run causes the application to run without stopping at the breakpoints. A debug perspective will open and you will see the debug perspective icon on the left side of your screen. Use the Run menu to see your choices, including the usual items such as Step into, Step over, Resume, and so on. For now, press F6 to step over our line of code and notice the output appear in the lower console window. Press F8 to complete execution.

    Figure 13. The debug perspective

  18. When you have finished, right-click on the debug perspective icon to close the debug perspective. Alternatively, you may click on Window=>Close perspective.

Want more speed?
So far, you've seen a fastpath for running and debugging applications. For testing a few lines of code, there's an even quicker path: the scrapbook page.

  1. To see it in action, take your "Hello, World" project. If you are not already viewing the Java perspective, click the navigation button on the left to return to the Java perspective.
  2. Now select the Hello project, then right-click on it and select New => Scrapbook page.

    Figure 14. Creating a scrapbook page

  3. Enter Scrap for the scrapbook file name and click Finish. You will return to the Java perspective with the Scrap.jpage file open.

    Figure 15. Scrap.jpage in the Java perspective

  4. Now type the same line of code in that we used before: System.out.println("Hello, World"). You can still use code-assist to complete method names. Select the line of code, right-click on it, and select Run snippet. The line of code will be compiled and executed. You don't need a main, or any other method definition, to test it.

    Figure 16. Entering a code snippet

  5. After the code runs, you will see the result in the console pane at the bottom of the Site Developer window:

    Figure 17. Running a code snippet

  6. The asterisk in front of the scrap.jpage tab indicates that you have not yet saved the file. Select Ctrl-S to save it, and the asterisk will disappear.

That is all there is to it! "Hello World" in under two minutes.

Summary
While WebSphere Studio Site Developer is a great tool for developing complex, multi-tier J2EE applications, it also excels at quick development of simple applications. With its unique task-oriented interface and its ability to switch perspectives, it is the tool of choice for all kinds of development tasks. Give it a try and you'll soon be on your way to increased productivity.

Resources

About the authors
Tom Mitchell is an application architect with the WebSphere Technical Sales Support team at IBM. He spends most of his time helping customers understand the WebSphere family of products, how it implements the J2EE specifications, and where it is going in the future. He is a co-author of Professional Java Fundamentals (WROX Press, 1996). It is a "must have" for people still developing AWT applications for Java 1.0. You can contact Tom at tommitch@us.ibm.com.


Currently researching Linux technology for the developerWorks Linux zone, Ian Shields is a Senior Programmer at IBM at the Research Triangle Park, NC. He joined IBM in Canberra, Australia, as a systems engineer in 1973, and has since worked on communications systems and pervasive computing in Montreal, Canada, and RTP, NC. He has several patent filings and seven issued patents. His undergraduate degree is in pure mathematics and philosophy from the Australian National University. He received an M.S. in computer science from North Carolina State University, where he is now pursuing a Ph.D. You can contact Ian at ishields@us.ibm.com.



e-mail it!
Rate this article

This content was helpful to me:

Strongly disagree (1)Disagree (2)Neutral (3)Agree (4)Strongly agree (5)

Comments?



developerWorks > Linux >
developerWorks
  About IBM  |  Privacy  |  Terms of use  |  Contact