A POJO is just a plain, old Java Bean with the restrictions removed. Java Beans must meet the following requirements:

  1. Default no-arg constructor
  2. Follow the Bean convention of getFoo (or isFoo for booleans) and setFoo methods for a mutable attribute named foo; leave off the setFoo if foo is immutable.
  3. Must implement java.io.Serializable

POJO does not mandate any of these. It's just what the name says: an object that compiles under JDK can be considered a Plain Old Java Object. No app server, no base classes, no interfaces required to use.

The acronym POJO was a reaction against EJB 2.0, which required several interfaces, extended base classes, and lots of methods just to do simple things. Some people, Rod Johnson and Martin Fowler among them, rebelled against the complexity and sought a way to implement enterprise scale solutions without having to write EJBs.

Martin Fowler coined a new acronym.

Rod Johnson wrote "J2EE Without EJBs", wrote Spring, influenced EJB enough so version 3.1 looks a great deal like Spring and Hibernate, and got a sweet IPO from VMWare out of it.

Here's an example that you can wrap your head around:

public class MyFirstPojo
{
    private String name;

    public static void main(String [] args)
    {
       for (String arg : args)
       {
          MyFirstPojo pojo = new MyFirstPojo(arg);  // Here's how you create a POJO
          System.out.println(pojo); 
       }
    }

    public MyFirstPojo(String name)
    {    
        this.name = name;
    }

    public String getName() { return this.name; } 

    public String toString() { return this.name; } 
}
Answer from duffymo on Stack Overflow
Top answer
1 of 11
85

A POJO is just a plain, old Java Bean with the restrictions removed. Java Beans must meet the following requirements:

  1. Default no-arg constructor
  2. Follow the Bean convention of getFoo (or isFoo for booleans) and setFoo methods for a mutable attribute named foo; leave off the setFoo if foo is immutable.
  3. Must implement java.io.Serializable

POJO does not mandate any of these. It's just what the name says: an object that compiles under JDK can be considered a Plain Old Java Object. No app server, no base classes, no interfaces required to use.

The acronym POJO was a reaction against EJB 2.0, which required several interfaces, extended base classes, and lots of methods just to do simple things. Some people, Rod Johnson and Martin Fowler among them, rebelled against the complexity and sought a way to implement enterprise scale solutions without having to write EJBs.

Martin Fowler coined a new acronym.

Rod Johnson wrote "J2EE Without EJBs", wrote Spring, influenced EJB enough so version 3.1 looks a great deal like Spring and Hibernate, and got a sweet IPO from VMWare out of it.

Here's an example that you can wrap your head around:

public class MyFirstPojo
{
    private String name;

    public static void main(String [] args)
    {
       for (String arg : args)
       {
          MyFirstPojo pojo = new MyFirstPojo(arg);  // Here's how you create a POJO
          System.out.println(pojo); 
       }
    }

    public MyFirstPojo(String name)
    {    
        this.name = name;
    }

    public String getName() { return this.name; } 

    public String toString() { return this.name; } 
}
2 of 11
29

POJO:- POJO is a Java object not bound by any restriction other than those forced by the Java Language Specification.

Properties of POJO

  1. All properties must be public setter and getter methods
  2. All instance variables should be private
  3. Should not Extend prespecified classes.
  4. Should not Implement prespecified interfaces.
  5. Should not contain prespecified annotations.
  6. It may not have any argument constructors

Example of POJO

public class POJO {

    private String value;

    public String getValue() {
         return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › pojo class in java
POJO Class in Java: A Comprehensive Tutorial | upGrad
April 2, 2025 - A Step-by-Step Illustration of a Basic POJO Class in Java · Define the class with public accessibility. Establish private attributes to hold the object's information. Create a constructor to set up the attributes.
People also ask

Why is POJO used in Java?
POJOs are used for increasing the readability and reusability of a program. POJOs have gained the most acceptance because they are easy to write and understand. POJO has no particular naming convention for properties and methods, or any other special restrictions.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › pojo class in java
POJO Class in Java: A Comprehensive Tutorial | upGrad
How do POJO classes work with Hibernate?
In Hibernate, POJO (Plain Old Java Object) classes represent database entities, and Hibernate uses these classes to map database tables to Java objects, allowing for object-relational mapping (ORM). You can think of POJOs as the building blocks for your data model, and Hibernate handles the persistence and retrieval of these objects to and from the database.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › pojo class in java
POJO Class in Java: A Comprehensive Tutorial | upGrad
Is a POJO always serializable?
All JavaBeans are POJOs but not all POJOs are JavaBeans. Serializable, i.e. they should implement the Serializable interface. Still, some POJOs that don't implement a Serializable interface are called POJOs because Serializable is a marker interface and therefore not of many burdens.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › pojo class in java
POJO Class in Java: A Comprehensive Tutorial | upGrad
🌐
Futurestud.io
futurestud.io › tutorials › gson-automatically-generate-pojo-classes-from-json-response
Gson — Automatically Generate POJO Classes from JSON Response
In this tutorial, you'll explore two options to automatically generate the POJO classes. The idea is straight-forward: simply paste an example JSON and get appropriate Java POJO classes back from the tool.
🌐
Medium
medium.com › @omartaiseerr › creating-dynamic-pojos-with-compilation-in-runtime-a04af573578
Creating Dynamic POJOs with Compilation in Runtime | by O M A R | Medium
April 15, 2023 - With the help of JavaPoet (open-source), we can generate these classes at runtime, based on external input such as a JSON file. This can be achieved through reflection and code generation techniques.
Find elsewhere
🌐
Oracle
docs.oracle.com › cd › E19182-01 › 821-0873 › ug_pojose-projects_c › index.html
Creating POJO Service Engine Projects (Sun POJO Service Engine User's Guide)
This wizard includes the steps ... generates the WSDL file. Right-click in the NetBeans Projects window, and then select New Project. The New Project Wizard appears. Under Categories, select Java; under Projects, select Java Application....
🌐
Baeldung
baeldung.com › home › java › core java › what is a pojo class?
What Is a Pojo Class? | Baeldung
June 11, 2024 - We’ll look at how a POJO compares to a JavaBean, and how turning our POJOs into JavaBeans can be helpful. When we talk about a POJO, what we’re describing is a straightforward type with no references to any particular frameworks. A POJO has no naming convention for our properties and methods. Let’s create a basic employee POJO. It’ll have three properties; first name, last name, and start date: public class EmployeePojo { public String firstName; public String lastName; private LocalDate startDate; public EmployeePojo(String firstName, String lastName, LocalDate startDate) { this.firstName = firstName; this.lastName = lastName; this.startDate = startDate; } public String name() { return this.firstName + " " + this.lastName; } public LocalDate getStart() { return this.startDate; } }
🌐
Scaler
scaler.com › home › topics › pojo class in java
POJO Class in Java - Scaler Topics
April 5, 2024 - Instantiate the POJO class: Create an object of the POJO class using the new operator. Set values: Set the values of the POJO class fields using the setter methods. Get values: Retrieve the values of the POJO class fields using the getter methods.
🌐
GeeksforGeeks
geeksforgeeks.org › java › hibernate-create-pojo-classes
Hibernate - Create POJO Classes - GeeksforGeeks
July 23, 2025 - POJO stands for Plain Old Java Object. In simple terms, we use POJO to make a programming model for declaring object entities. The classes are simple to use and do not have any restrictions as compared to Java Beans.
🌐
GitHub
github.com › mkarneim › pojobuilder
GitHub - mkarneim/pojobuilder: A Java Code Generator for Pojo Builders
@AppPojo @GeneratePojoBuilder(intoPackage = "builder") public class Contact { public String name; } This generates FluentContactBuilder in the package builder. The PojoBuilder wiki offers a cookbook on using PojoBuilder to create a domain-specific language for tests. Find complete code examples in the src/testdata/java/samples folder.
Starred by 334 users
Forked by 43 users
Languages   Java 100.0% | Java 100.0%
🌐
Makeseleniumeasy
makeseleniumeasy.com › 2020 › 06 › 08 › rest-assured-tutorial-29-how-to-create-pojo-classes-of-a-json-payload
REST Assured Tutorial 29 – How to create POJO classes of a JSON Object Payload
As a part of End to End REST Assured Tutorial , in this post We will learn to create a simple POJO class for a simple JSON Object payload. POJO classes are extensively used for creating JSON and XML payloads for API. Although there are many online platform to generate POJO and Java libraries to generate POJO classes automatically ...
🌐
Board Infinity
boardinfinity.com › blog › pojo-class-know-how-to-create
Pojo Class in Java: How to Create? | Board Infinity
August 19, 2025 - The POJO class must get declared as a public class. The public default constructor is mandatory. There may be arguments in the constructor. The values of all objects must be accessible by other Java programs through public Getters and Setters.
🌐
GroTechMinds
grotechminds.com › home › creating and using pojo classes in restassured for api testing
Creating and Using POJO Classes in RestAssured for API Testing
February 27, 2025 - Learn how to create and use POJO classes in RestAssured for efficient API testing. This guide covers step-by-step instructions and best practices for working with RestAssured and POJOs in your API test automation.
🌐
TechVidvan
techvidvan.com › tutorials › java-pojo-class
Java POJO class - Plain Old Java Object - TechVidvan
June 8, 2020 - They can have any access modifiers like public, private, default, or protected. You can also note that in POJO class there is no need to add any constructor. We can use the POJO class in any Java code. POJO class is not tied to the framework.
🌐
DataFlair
data-flair.training › blogs › pojo-class-in-java
POJO Class in Java (Plain Old Java Object with Example) - DataFlair
September 14, 2018 - POJO Class in Java - What is Plain Old Java Object, Example of POJO Class in Java, Java POJO Tutorial, Extend pre-specified classes in Java POJO
🌐
Jsonschema2pojo
jsonschema2pojo.org
jsonschema2pojo
If additionalProperties is specified and set to the boolean value false, then the generated Java type does not support additional properties. If the additionalProperties node is undefined (not present), null or empty, then a new bean property named "additionalProperties", of type Map<String,Object> is added to the generated type (with appropriate accessors). The accessors are annotated to allow Jackson to marshal/unmarshal unrecognised (additional) properties found in JSON data from/to this map. ... public class MyObject { private java.util.Map<String, Object> additionalProperties = new java.u
🌐
HCL GUVI
studytonight.com › java-examples › java-pojo-class
Java POJO Class
Zen Classes are HCL GUVI's most refined and flagship product—live, expert-led tech programs for beginners and pros.