Keeping beans and BeanInfo classes in different projects
When you develop classes in the visual editor for Java, you have the option to keep your .java files and BeanInfo classes in different projects. This enables you to easily develop and deploy the classes separately.
For example, MyProject contains the class runtimeclasses.MyJavaBean. A second project, MyBeanInfoProject, contains the package beaninfoclasses.MyJavaBeanBeanInfo.
Because a BeanInfo class needs to know the class it represents, MyBeanInfoProject must include MyProject in its Java build path. Note that the reverse is not true - MyProject should not include MyBeanInfoProject in its Java build path, because this creates a circular reference.
To configure your workbench setup so that BeanInfo classes are stored in a different project from your .java files:
- In the Java perspective, right-click the project that contains the BeanInfo classes and select Properties from the pop-up menu. The Properties window opens.
- Select Java Build Path. Click the Projects tab and add the project that contains the Java beans (.java files) to the build path. This defines the location of any classes required at run time that are not part of the current project. You have now met the prerequisite explained above. Close this Properties window.
- Open the Properties window for the project that contains the .java files and select BeanInfo Path. Click the BeanInfo classes tab.
- Click the Add Projects push button. A dialog box that lists all available projects opens. You can use the text field at the top of the dialog box to filter the list. Once you find the project containing the BeanInfo classes select it and click OK.
- The project will now be included in the class path of the virtual machine used for introspection, but you also need to specify the packages that contain the BeanInfo classes. To do this, select the project that contains the BeanInfo classes, and click the Modify Paths push button. In the Modify Searchpaths dialog box that opens, select the package containing the BeanInfo class by clicking Choose Packages. The Select Packages dialog box opens, showing a tree view of packages inside the project.
- Select the package that contains the BeanInfo classes. If there is more than one package you can select them in turn. You can also use the Up and Down push buttons to control the order in which they will be searched.
The steps to specify the location of a project's BeanInfo classes when they are in another project are now complete.
Notes:
- If you develop classes in yet another project and they reference classes in the project whose BeanInfo path you just configured (that is, the former project has the latter on its Java build path), ensure that the project containing the BeanInfo classes is exported. Otherwise, those classes will not be found at introspection time. In the BeanInfo Path properties for the project that contains the referenced beans, click the Order and export tab and confirm that the packages containing BeanInfo classes are selected. Then select the Java Build Path properties for the same project and confirm that the packages containing the BeanInfo classes are not excluded from export there. Excluding them here overrides including them on the BeanInfo Path page.
- If a BeanInfo package export flag cannot be changed, the given export status is required. For example, if a package is not exported in the Java Build Path, then it cannot be exported in the BeanInfo search path and may also not be set to not exported. This can happen if package is marked as exported in the Java Build Path. For BeanInfo packages that come from non-java build path locations, then the export flag can be changed. Also note that if you change the Java Build path you need to close the properties dialog and reopen it to see the changes in the BeanInfo path page. This is because the Java Build path changes are not actually applied until the window is closed.
- Currently, by default, whenever an entry is added to the BeanInfo classes it is not exported, so always go to the Order and Export page, and explicitly export the entry.
Parent topic
Specifying the location of BeanInfo classes
Related concepts
BeanInfo classes and introspection
Related tasks
Keeping beans and BeanInfo classes in different packages in the same project
Keeping BeanInfo classes in a JAR file
Explicitly defining the location of BeanInfo classes
Keeping beans and BeanInfo classes in the same package