Testing a Java bean

Once you have written a class using the Visual Editor for Java you may wish to run it to test the runtime behavior. If the class has a public static void main(String[]) method you can use the menu option Run > Java Application. When you write a Java bean using the Visual Editor for Java however it will not typically have a main method. Rather than having to add a main method, to allow you to test Java beans classes there is an additional option available from the Run menu called Java bean that invokes a Java bean launcher.

To test a class select it and use the menu option Run As > Java bean. This will create a launch configuration that is then used to start a virtual machine that instantiates the class and lets it be tested. Before creating a launch configuration the existing configuration are search, and if one is already there for the Java bean class then it will be re-used. The Java process created can be seen by switching to the debug perspective. If you wish to debug you Java bean while you are testing it you can use the menu option Debug As > Java bean that allows you to use breakpoints and step through the code.

Related tasks
The Java bean launcher
Testing applets

(C) Copyright IBM Corporation 2000, 2003. All Rights Reserved.