⬅ Previous Next ➡

Java Projects & Practice

Hands-on Java Mini Projects: Student Management, Banking, Library, CRUD Apps & Final Project
  • Mini projects help you practice Java concepts like OOP, collections, file handling, JDBC, and exception handling.
  • Below are practical project ideas with small code starter examples (non-copyright).

1) Student Management System (Console / CRUD)

  • Features:
    • Add student (id, name, course, marks)
    • View all students
    • Search by id
    • Update marks
    • Delete student
  • Concepts: classes/objects, ArrayList, loops, switch-case.
import java.util.ArrayList;
import java.util.Scanner;

class Student {
    int id;
    String name;
    String course;
    int marks;

    Student(int id, String name, String course, int marks) {
        this.id = id;
        this.name = name;
        this.course = course;
        this.marks = marks;
    }

    public String toString() {
        return id + " | " + name + " | " + course + " | " + marks;
    }
}

class StudentManagement {
    static ArrayList<Student> list = new ArrayList<>();

    static Student findById(int id) {
        for (Student s : list) {
            if (s.id == id) return s;
        }
        return null;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            System.out.println("\n1.Add 2.View 3.Search 4.Update 5.Delete 6.Exit");
            int ch = sc.nextInt();
            sc.nextLine();

            if (ch == 1) {
                System.out.print("Id: ");
                int id = sc.nextInt();
                sc.nextLine();
                System.out.print("Name: ");
                String name = sc.nextLine();
                System.out.print("Course: ");
                String course = sc.nextLine();
                System.out.print("Marks: ");
                int marks = sc.nextInt();

                list.add(new Student(id, name, course, marks));
                System.out.println("Student Added!");

            } else if (ch == 2) {
                System.out.println("---- Students ----");
                for (Student s : list) System.out.println(s);

            } else if (ch == 3) {
                System.out.print("Enter id to search: ");
                int id = sc.nextInt();
                Student s = findById(id);
                System.out.println(s == null ? "Not Found" : s);

            } else if (ch == 4) {
                System.out.print("Enter id: ");
                int id = sc.nextInt();
                Student s = findById(id);
                if (s != null) {
                    System.out.print("New marks: ");
                    s.marks = sc.nextInt();
                    System.out.println("Updated!");
                } else {
                    System.out.println("Not Found");
                }

            } else if (ch == 5) {
                System.out.print("Enter id: ");
                int id = sc.nextInt();
                Student s = findById(id);
                if (s != null) {
                    list.remove(s);
                    System.out.println("Deleted!");
                } else {
                    System.out.println("Not Found");
                }

            } else if (ch == 6) {
                System.out.println("Exit...");
                break;
            } else {
                System.out.println("Invalid choice!");
            }
        }

        sc.close();
    }
}

2) Banking System (OOP + Exceptions)

  • Features:
    • Create account
    • Deposit / Withdraw
    • Balance check
    • Transaction validation using exceptions
  • Concepts: encapsulation, custom exception, methods.
class InsufficientBalanceException extends Exception {
    InsufficientBalanceException(String msg) {
        super(msg);
    }
}

class BankAccount {
    private String holder;
    private double balance;

    BankAccount(String holder, double balance) {
        this.holder = holder;
        this.balance = balance;
    }

    void deposit(double amt) {
        if (amt > 0) balance += amt;
        System.out.println("Deposited: " + amt);
    }

    void withdraw(double amt) throws InsufficientBalanceException {
        if (amt > balance) {
            throw new InsufficientBalanceException("Not enough balance!");
        }
        balance -= amt;
        System.out.println("Withdraw: " + amt);
    }

    void show() {
        System.out.println("Holder: " + holder + " | Balance: " + balance);
    }
}

class BankingDemo {
    public static void main(String[] args) {
        BankAccount acc = new BankAccount("Sourav", 1000);

        acc.deposit(500);
        acc.show();

        try {
            acc.withdraw(2000);
        } catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
        }

        acc.show();
    }
}

3) Library Management System

  • Features:
    • Add books
    • Issue/Return book
    • Search book by name/id
    • Available / issued status
  • Concepts: collections, classes, loops, file/JDBC optional.
import java.util.ArrayList;

class Book {
    int id;
    String title;
    boolean issued;

    Book(int id, String title) {
        this.id = id;
        this.title = title;
        this.issued = false;
    }

    public String toString() {
        return id + " | " + title + " | " + (issued ? "Issued" : "Available");
    }
}

class LibraryDemo {
    public static void main(String[] args) {
        ArrayList<Book> books = new ArrayList<>();

        books.add(new Book(1, "Java Basics"));
        books.add(new Book(2, "DBMS Notes"));

        // Issue book id 1
        for (Book b : books) {
            if (b.id == 1) b.issued = true;
        }

        for (Book b : books) System.out.println(b);
    }
}

4) CRUD Application (JDBC + MySQL)

  • Build a CRUD app that stores records in MySQL.
  • Features:
    • Insert record using PreparedStatement
    • Select records and display using ResultSet
    • Update record
    • Delete record
  • Concepts: JDBC connection, SQL exception handling.
// Basic JDBC CRUD steps (outline)
import java.sql.*;

class JdbcCrudOutline {
    static final String URL = "jdbc:mysql://localhost:3306/school_db";
    static final String USER = "root";
    static final String PASS = "";

    public static void main(String[] args) {
        try (Connection con = DriverManager.getConnection(URL, USER, PASS)) {

            // CREATE
            PreparedStatement ins = con.prepareStatement(
                "INSERT INTO students(name, email) VALUES (?, ?)"
            );
            ins.setString(1, "Sourav");
            ins.setString(2, "souravshu562@gmail.com");
            ins.executeUpdate();

            // READ
            PreparedStatement sel = con.prepareStatement(
                "SELECT id, name, email FROM students LIMIT 5"
            );
            ResultSet rs = sel.executeQuery();
            while (rs.next()) {
                System.out.println(rs.getInt("id") + " " + rs.getString("name"));
            }

        } catch (SQLException e) {
            System.out.println("SQL Error: " + e.getMessage());
        }
    }
}

5) Final Java Project (Recommended)

  • Project Idea: School / Coaching Management System (Console + JDBC + Optional GUI)
  • Modules (suggested):
    • Login (Admin/Staff)
    • Student CRUD
    • Course/Class management
    • Fees management (fee collection + receipts)
    • Attendance module
    • Reports (export to file / print)
  • Tech stack:
    • Java + JDBC + MySQL
    • Optional: Swing GUI
    • Optional: JSON export/import

6) Quick Notes (How to Improve Projects)

  • Start with console version → then add JDBC → then add GUI.
  • Use classes for models (Student, Book, Account).
  • Use ArrayList/Map for temporary storage.
  • Use exceptions for validations.
  • Write clean menus using switch-case.
⬅ Previous Next ➡