Skip to content
Laviyx Learn

Try

Mini project

Library Management System in Java

A console library system in Java that manages books and members, issues and returns books with due dates, calculates fines, and saves everything to files between runs.

Intermediate 2–3 weeks 1–2 studentsUpdated

Java 21OOPCollectionsjava.timeFile I/O

The problem

A college library tracks which books are available, who has borrowed what, and who is late. Doing this in a register makes it slow to answer simple questions like "is this book in?" or "which books are overdue?".

This project models the library with classes and collections, so each question becomes a method call. It is a classic way to show you understand object-oriented design.

Features to build

  • Add, search (by title, author or ISBN) and remove books, with the number of copies
  • Register members with a member ID and a borrowing limit
  • Issue a book: check copies are available and the member is under the limit, then set a due date 14 days ahead
  • Return a book and calculate a fine per day late
  • List overdue books and the members who have them
  • Save books, members and loans to files on exit and load them on start
  • Custom exceptions such as BookNotAvailableException with clear messages

Suggested data model

ClassMain fields
Bookisbn, title, author, totalCopies, availableCopies
MembermemberId, name, maxBooks
Loanbook, member, issueDate, dueDate, returnDate
LibraryMap<String, Book> by ISBN, Map<String, Member> by ID, List<Loan>

Keep the rules (limits, fines, availability) inside Library methods, not in main.

Build plan

  1. 1

    Design the classes

    Draw the four classes and their fields. Decide which class owns each rule, for example Library.issueBook checks availability and the member's limit.

  2. 2

    Write the model classes

    Use private fields, constructors and getters. A record works well for simple values that never change.

  3. 3

    Choose collections

    A HashMap keyed by ISBN gives fast lookups by ISBN. Keep loans in an ArrayList and filter them for active and overdue loans.

  4. 4

    Issue, return and fine logic

    Use LocalDate.now() and plusDays(14) for due dates, and ChronoUnit.DAYS.between for days late.

  5. 5

    Exceptions

    Create checked or unchecked exceptions for not available, limit reached and not found, and catch them in the menu to show a message.

  6. 6

    Saving and loading

    Write each object as one line of comma-separated values and parse it back on start. Handle a missing file on the first run.

  7. 7

    Menu, testing and README

    Build a switch-based menu, test every rule with edge cases (last copy, limit reached, return late) and document how to run it.

Learn these first

Each part of the project is taught in one of these free lessons.

Make it stand out

  • Separate student and staff members with different limits, using inheritance
  • Reserve a book that is currently issued, with a queue of waiting members
  • Store data in a database with JDBC instead of files
  • Reports with streams: most borrowed books and most active members

Viva and interview questions

Try to answer each one aloud before you open it.

  • Why did you use a HashMap for books?

    Lookups by ISBN are the most common operation. A HashMap finds a key in constant time on average, while searching a list would check every book.

  • What is encapsulation in your project?

    Fields like availableCopies are private and only change through methods such as issueBook and returnBook, which check the rules. Other code cannot set an invalid value directly.

  • How do you calculate the fine?

    I find the days between the due date and the return date with ChronoUnit.DAYS.between. If it is positive, the fine is that number multiplied by the fine per day.

  • Checked or unchecked exception: which did you choose and why?

    Checked exceptions force the caller to handle them, which suits expected situations like a book not being available. Unchecked exceptions are for programming errors. Either choice is fine if you can explain it.

  • How would you add staff members who can borrow more books?

    Create a StaffMember class that extends Member and gives a higher limit, or store the limit as a field set by member type. The Library code keeps working because it uses the Member type.

What to put in your project report

  1. Abstract: the problem, your solution and the result in one paragraph.
  2. Introduction and problem statement: who has the problem and why it matters.
  3. Requirements: the features (functional) and qualities such as speed and security (non-functional).
  4. Design: architecture diagram, database tables or data flow, and screen layouts.
  5. Implementation: the main modules and the most interesting code, explained.
  6. Testing: the test cases you ran, with inputs, expected and actual results.
  7. Results: screenshots or numbers that show the project working.
  8. Conclusion and future scope: what you achieved and what you would add next.

Your college may give its own format. Follow that first, and use this list to check nothing is missing.

All project ideas →