This project demonstrates a complete Java application with proper package structure and separation of concerns.
Project Structure
src/com/example/library/
├── model/
│ ├── Book.java # Book entity/model
│ └── Member.java # Member entity/model
├── service/
│ └── LibraryService.java # Business logic
├── util/
│ └── ValidationUtil.java # Utility functions
└── main/
└── LibraryApp.java # Main application entry point
How to Compile and Run
Using Command Line:
- Navigate to the projects directory:
cd projects
- Compile all Java files:
javac -d bin src/com/example/library/**/*.java
- Run the application: -cp: classpath
java -cp bin com.example.library.main.LibraryApp
Using IDE (IntelliJ IDEA, Eclipse, VS Code):
- Import the project
- Set
srcas source root - Run
LibraryApp.java
Key Concepts Demonstrated
- Packages: Organized code into logical packages
- Model Classes: Represent data entities (Book, Member)
- Service Layer: Contains business logic (LibraryService)
- Utility Classes: Reusable helper methods (ValidationUtil)
- Main Class: Application entry point
- Encapsulation: Private fields with public getters/setters
- Collections: Using Map, List for data storage
- Streams: Using Java 8+ streams for operations
Features
- Add/Remove books and members
- Search books by title or author
- Borrow and return books
- Track member borrowing history
- Validation of ISBN and email
- Statistics and reporting