Problem solve Get help with specific problems with your technologies, process and projects.

What is a Java Bean? Why it is useful in J2EE?

What is a Java Bean? Why it is useful in J2EE?

A Java Bean is a software component written in the Java programming language that conforms to the JavaBeans component specification. The JavaBeans APIs became part of the "core" Java APIs as of the 1.1 release of the JDK.  

The JavaBeans specification defines a Java-based software component model that adds a number of features to the Java programming language. Some of these features include:

* introspection 

* customization 

* events 

* properties 

* persistence  

Java Beans are used throughout J2EE as a universal contract for runtime discovery and access. For example, JavaServer Pages (JSP) uses Java Beans as data transfer objects between pages or between servlets and JSPs. J2EE's JavaBeans Activation Framework uses Java Beans for integrating support for MIME data types into J2EE. The J2EE Management API uses JavaBeans as the foundation for the instrumentation of resources to be managed in a J2EE environment.

Dig Deeper on Topics Archive

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

From what I can make out, a JavaBean is basically a class just like any other java class except that it adheres to certain conventions, i.e.:

The class must implement Serializeable
Class properties are assumed to be private and their names start with a lowercase letter
Each property must have it's respective getter and setter methods.
Each setter method starts with the prefix 'get' followed by the property name e.g. setName()
Setter methods are public and void
Same applies to the getter methods (prefix 'get', public, return type respective property class type etc.)
For boolean properties instead of 'get' one uses the prefix 'is'
Strictly speaking it is the instance of the class that is considered a 'bean' not the class itself.