The Jakarta Commons BeanUtilsS library features a variety of functionality for working with JavaBeansW. The 1.7.0 version of BeanUtils has a dependency on the CommonsSW Logging library. Additionally, in this tutorial, I make use of the ToStringBuilder in the Commons LangS library to output the properties of the JavaBeans in this example.

The jarW files are added to my lib/ directory and added to my project's build path, as shown below.

This project features two beans. The first bean, FromBean, has three properties: name, aProp, and bProp.

The BeanUtilsCopyPropertiesTest class will let us test copying properties from one bean to another. First, it creates a fromBean object and a toBean object. It outputs these objects to the console. Then, it call the BeanUtils.copyProperties() method with toBean as the first parameter and fromBean as the second parameter. Notice that the object that is copied to is the first parameter and the object that is copied from is the second parameter. In my opinion, the ordering of the parameters is a little backwards, but the person who wrote this method probably came from a C background and as a result was comfortable with this ordering. Following the copyProperties call, the object properties of fromBean and toBean are output to the console.