What is a Java Bean and a Java POJO ?
As a Java developer, you are surely used to read these terms in Java articles or blogs. Often, authors speak you about Java Bean or POJO (Plain Old Java Objects). But, some developers don’t know really what is behind these acronyms.
To be clear, this is the definition for both terms.
The term of POJO has been used the first time by Martin Fowler, Rebecca Parsons an Josh MacKenzie in September 2000 and denotes a Java object not bound by any restriction other than those forced by Java Language Specification.
Thus, a POJO can’t be a class extending HttpServlet for example.
A Java Bean is a POJO but with more conventions to apply. Java Bean specification is a standard that forces to follow constraints :
- All properties must be private with getters / setters
- A Java Bean must have a no-argument public constructor
- A Java Bean must implement Serializable interface
It’s just a convention mostly used in Java Enterprise Edition (Java EE) platform from Oracle. Nothing of extraordinary but it’s important to keep these definitions in mind for Java developers.