Running a Java bean or application
While you are developing your visual class, you can run it to see its appearance and behavior.
When you run a Java bean or application using the visual editor, a virtual machine is created that uses the class path specified in the Java Build Path of the project. The Java bean is then instantiated using its null constructor. If the Java bean is a visual class (is a subclass of java.awt.Component), an appropriate window is created to host the visual Java bean. If the bean is part of or inherits from an AWT Java bean, the window is a java.awt.Dialog. If the bean is a Swing class or inherits from a Swing class, the window is a javax.swing.JDialog. If the bean is an SWT class, the window is an SWT Shell. If the visual Java bean does not require a window because it itself is one, the Java bean will be made visible and given a default size after it has been instantiated.
When you run a class as a Java bean or application, a launch configuration is automatically created. The launch configuration is used to start a virtual machine that instantiates the class and allows it to be tested. If a launch configuration already exists for the class you are running, that launch configuration will be used.
To run a visual class as a Java bean or application:
- Open your visual Java class in the visual editor.
- From the main menu, select one of the following options:
- Run > Run As > Java Application if your class has a public static void main(String[]) method.
- Run > Run As > Java bean if your class has no main method.
If an SWT class is being run as a Java application, the SWT library must be added to the java.library path. See the SWT documentation for details. If you run the SWT class as a Java bean, the visual editor handles this for you.
A virtual machine that instantiates the class is started, and the Java bean or application runs on top of the workbench. You can then test the behavior and performance of your Java class.
Parent topic
Testing and debugging in the visual editor
Related tasks
Configuring options for running a Java bean or application
Testing and deploying applets
Testing and debugging in the visual editor
Debugging a visual Java bean or application