简体   繁体   中英

JavaBeans Classes in Separate JAR Files

Is it possible to build classes for a JavaBean in separate JAR files? Specifically- a JavaBean has the Bean and BeanInfo classes in one JAR file and the Custom Property Editor class inn a different JAR, the JAR file with the Bean and BeanInfo classes has the JAR file with the Custom Property Editor class on the classpath, but during drag and drop of the JavaBean in an IDE, a class not found exception is thrown for the Custom Property Editor class. Are all classes for a given JavaBean required to be built into the same JAR file?

The PropertyEditorManager looks for the property editor (JavaBean spec):

  1. by looking if an editor has been registered explicitly. Since you are using drag and drop I suppose this is not a good solution for you.
  2. looking for 'package.BlahEditor' where 'package.Blah' is your JavaBean. So the names have to be correct for the IDE to find the editor.
  3. looking for BlahEditor in a searchlist defined by the container. Again, since you are using drag and drop this is not a solution.

I don't think that there is a problem using different jars, or packaging the editor in a separate jar.

I do not have enough information to give a conclusive but I can only suggest to check the naming conventions of your property editor against the name of your JavaBean.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM