Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
Inventory Management System in Java
Next article icon

Inventory Management System in Java

Last Updated : 09 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

An inventory management system is very important for businesses to keep track of their stocks, manage orders, and maintain an accurate record. With the help of this project, the user can add, remove, and view items in the inventory. Also beginners can learn important concepts like classes, generics, and handling user input.

In this article, we are going to build a simple inventory management system in Java. This system helps us perform important tasks like adding, removing, and viewing items in the inventory. The implementation will be divided into multiple classes for better code organization and understanding.

Working of the Inventory System

Here is how the inventory management system is going to work:

  • The user can add items by giving details like item name, quantity, and price.
  • The user can remove items from the inventory by telling the item's name.
  • The user can also view all items in the inventory.
  • The system displays the inventory status after each operation.

Project Structure

The image below demonstrates the project structure.

ProjectStructure

We will organize the code into these parts which are listed below:

  • Item Class: This class represents an item with all the attributes like name, quantity and price.
  • Inventory Class: This class handles all the inventory operations like adding, removing and viewing items.
  • InventorySystem Class: This is the main class that runs the system and takes input from the user.

Let's now try to implement the code.

Java Inventory Management System Project Implementation

1. Item Class

This class represents all the inventory item. It includes attributes like name, quantity and price of the item.

Item.java:

Java
package com.inventory;  public class Item {     private String name;     private int quantity;     private double price;      // Constructor     public Item(String name, int quantity, double price) {         this.name = name;         this.quantity = quantity;         this.price = price;     }      // Getter and setter methods     public String getName() {         return name;     }      public void setName(String name) {         this.name = name;     }      public int getQuantity() {         return quantity;     }      public void setQuantity(int quantity) {         this.quantity = quantity;     }      public double getPrice() {         return price;     }      public void setPrice(double price) {         this.price = price;     }      @Override     public String toString() {         return "Item{name='" + name + "', quantity=" + quantity + ", price=" + price + "}";     } } 


2. Inventory Class

This class manages the list of items in the inventory. It allows us to add, remove and view items.

Inventory.java:

Java
package com.inventory;  import java.util.*;  public class Inventory<T> {     private List<T> items;      public Inventory() {         items = new ArrayList<>();     }      // Add an item to the inventory     public void addItem(T item) {         try {             items.add(item);             System.out.println("Item added successfully: " + item);         } catch (Exception e) {             System.out.println("Error adding item: " + e.getMessage());         }     }      // Remove an item from the inventory     public void removeItem(T item) {         try {             if (!items.contains(item)) {                 throw new IllegalArgumentException("Item not found in inventory.");             }             items.remove(item);             System.out.println("Item removed successfully: " + item);         } catch (Exception e) {             System.out.println("Error removing item: " + e.getMessage());         }     }      // View all items in the inventory     public void viewItems() {         if (items.isEmpty()) {             System.out.println("Inventory is empty.");         } else {             System.out.println("Inventory items:");             for (T item : items) {                 System.out.println(item);             }         }     }      // Getter method for items     public List<T> getItems() {         return items;     } } 


3. InventorySystem

This class is the entry point of the application. The main task of this class is to interact with the user, take inputs and perform actions like adding, removing, and viewing items in the inventory.

InventorySystem.java:

Java
package com.inventory;  import java.util.Scanner;  public class InventorySystem {     public static void main(String[] args) {         Inventory<Item> inventory = new Inventory<>();          Scanner scanner = new Scanner(System.in);         boolean exit = false;          while (!exit) {             System.out.println("\nInventory System");             System.out.println("1. Add item");             System.out.println("2. Remove item");             System.out.println("3. View items");             System.out.println("4. Exit");             System.out.print("Enter your choice: ");             int choice = scanner.nextInt();             scanner.nextLine();  // consume the newline              switch (choice) {                 case 1:                     // Add an item                     System.out.print("Enter item name: ");                     String name = scanner.nextLine();                     System.out.print("Enter item quantity: ");                     int quantity = scanner.nextInt();                     System.out.print("Enter item price: ");                     double price = scanner.nextDouble();                     scanner.nextLine();  // consume the newline                      Item newItem = new Item(name, quantity, price);                     inventory.addItem(newItem);                     break;                  case 2:                     // Remove an item                     System.out.print("Enter item name to remove: ");                     String itemNameToRemove = scanner.nextLine();                     Item itemToRemove = null;                      // Search for the item using the getter method for items                     for (Item item : inventory.getItems()) {                         if (item.getName().equalsIgnoreCase(itemNameToRemove)) {                             itemToRemove = item;                             break;                         }                     }                      if (itemToRemove != null) {                         inventory.removeItem(itemToRemove);                     } else {                         System.out.println("Item not found in inventory.");                     }                     break;                  case 3:                     // View items                     inventory.viewItems();                     break;                  case 4:                     // Exit                     exit = true;                     System.out.println("Exiting Inventory System.");                     break;                  default:                     System.out.println("Invalid choice. Please try again.");             }         }          scanner.close();     } } 

Output:

Output


How to Run the Project in IntelliJ IDEA?

To run the project on IntelliJ IDEA we just need to follow these steps which are listed below:

  • Open IntelliJ IDEA and create a new Java project.
  • Start creating the packages and the structure must be look like this:
    • Item.java
    • Inventory.java
    • InventorySystem.java
  • Create the classes in the correct packages
  • Save all the files.
  • Run the main class
InventoryManagementSystemIDE

Next Article
Inventory Management System in Java

M

musklf2s
Improve
Article Tags :
  • Java
  • Java Projects
Practice Tags :
  • Java

Similar Reads

    Inventory Management System using Spring Boot
    Inventory Management System plays an important role in Business for tracking the Inventory, and It is used for tracking and movement of goods. In this article, we have provided some basic functionality for the Inventory Management System like an Analysis report of goods, adding new Products to the S
    15 min read
    JUnit - Inventory Stock Testing as a Maven Project
    The quality of the software is very important. Though Unit tests and integration tests are done in the manual testing way, we cannot expect all kinds of scenarios to test. Hence as a testing mechanism, we can test a software code or project by means of JUnit. In this article let us see how to do tes
    4 min read
    Java.util Package in Java
    Java.util PackageIt contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).Following are the Important Classes in Java.util package
    4 min read
    Java Fundamentals Coding Practice Problems
    Understanding Java fundamentals is the first step to becoming a proficient Java programmer. This collection of Java basic coding practice problems covers essential topics such as input/output operations, arithmetic and logical operators, type conversion, conditional statements, loops, and more. Thes
    1 min read
    What is Java Enterprise Edition (Java EE)?
    In today's world of large-scale applications, businesses need secure, scalable, and efficient software solutions. Java Enterprise Edition (Java EE) now known as Jakarta EE provides a powerful framework for building enterprise-level applications. JEE has become the backbone of many banking, e-commerc
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences