A JavaFX + SQLite based second-hand trading platform that supports user registration, item posting, favorites, messaging, orders, reviews and admin management.
- Go to the project Releases page and download the latest installer:
SecondHandTrading-1.5.4.exe(~57 MB) - Double-click the installer and follow the wizard to complete installation.
- Launch SecondHandTrading from the Start Menu or the Desktop shortcut.
The installer bundles JDK 21 + JavaFX 23, so the target machine does not need Java pre-installed.
-
Download or build the portable package locally (see Building Executable Packages -
jpackagePortable). -
After extraction, the folder structure looks like:
SecondHandTrading/ ├── SecondHandTrading.exe # Main executable (double-click to run) ├── runtime/ # Bundled JDK 21 + JavaFX └── item_images/ # Product images (sample + user uploads) -
Double-click
SecondHandTrading.exeto run the app.
At runtime the database is created automatically under
C:\Users\<username>\.secondhand-trading\secondhand.db, so you do not need to ship a.dbfile with the app.
# Clone the repository
git clone https://github.com/fql9/3343-Project.git
cd 3343-Project
# Windows
.\gradlew.bat run
# macOS / Linux
./gradlew runAll accounts use password: password123
| Username | Role | Description |
|---|---|---|
| admin | ADMIN | Full system access |
| alice | SELLER | Has sold items |
| bob | SELLER | Active seller |
| charlie | BUYER | Regular buyer |
This project is a complete second-hand trading platform application that provides the following core features:
- User registration and login (supports buyer and admin roles)
- Item browsing and searching
- Item posting and management
- Favorites functionality
- Internal messaging system
- User management (admin feature)
| Component | Minimum | Recommended |
|---|---|---|
| Java | JDK 21 | JDK 21+ |
| RAM | 512 MB | 1 GB+ |
| Disk Space | 100 MB | 200 MB |
| OS | Windows 10 / macOS 10.14 / Linux | Latest version |
| Component | Version | Description |
|---|---|---|
| Java | 21 | Programming language |
| JavaFX | 23.0.1 | UI framework |
| SQLite | 3.46.0.0 | Embedded database |
| Gradle | 9.2.1 | Build tool |
| SLF4J | 2.0.16 | Logging framework |
| JUnit 5 | 5.10.2 | Testing framework |
| Mockito | 5.14.2 | Mocking framework |
3343-Project/
+-- src/
| +-- MainApp.java # Application entry point
| +-- config/
| | +-- DatabaseConfig.java # Database configuration
| +-- controller/ # Controller layer
| | +-- LoginController.java # Login controller
| | +-- MainController.java # Main interface controller
| | +-- BoardController.java # Item list controller
| | +-- ItemDetailController.java # Item detail controller
| | +-- MyItemsController.java # My items controller
| | +-- FavoritesController.java # Favorites controller
| | +-- MessageController.java # Message controller
| | +-- OrderHistoryController.java # Buyer order history
| | +-- SalesHistoryController.java # Seller sales history
| | +-- NotificationController.java # Notification center
| | +-- UserProfileController.java # User profile center
| | +-- UserManagementController.java # User management controller
| +-- dao/ # Data access layer
| | +-- impl/ # DAO implementations
| +-- model/ # Data models
| | +-- User.java
| | +-- Item.java
| | +-- Message.java
| | +-- Favorite.java
| | +-- Order.java
| | +-- Review.java
| | +-- Notification.java
| +-- service/ # Business logic layer
| | +-- UserService.java
| | +-- ItemService.java
| | +-- MessageService.java
| | +-- FavoriteService.java
| | +-- OrderService.java
| | +-- ReviewService.java
| | +-- NotificationService.java
| +-- util/ # Utility classes
| +-- DialogUtils.java # Dialog utilities
| +-- PasswordUtils.java # Password encryption utilities
| +-- ValidationUtils.java # Validation utilities
+-- build.gradle # Gradle build configuration
+-- settings.gradle # Gradle settings
+-- README.md # Project documentation
If you only use the installer or portable version, you can skip this section.
This is only required when developing from source or building packages yourself.
Choose one of the following options:
- Download Adoptium Temurin JDK 21
- Run the installer (.msi file)
- Important: Check "Set JAVA_HOME variable" during installation
- Verify installation:
java -version # Should show: openjdk version "21.x.x"
# Using Homebrew
brew install openjdk@21
# Add to PATH
echo 'export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# Verify
java -versionsudo apt update
sudo apt install openjdk-21-jdk
# Verify
java -versionJavaFX 23.0.1 is managed via Gradle dependencies and jpackage tasks. No separate installation is needed.
# Windows
.\gradlew.bat run
# macOS / Linux
./gradlew run# Windows
.\gradlew.bat fatJar
# macOS / Linux
./gradlew fatJar
# Run
java -jar build/libs/3343-Project-1.0-SNAPSHOT-all.jarNote: The Gradle Wrapper is included, so you do not need a local Gradle installation.
This project uses jpackage to generate a Windows installer and portable build, both bundling Liberica JDK 21 Full + JavaFX:
- All commands are run from the project root:
cd 3343-Project - On first run, Gradle will automatically download Liberica JDK Full (~200 MB), so internet access is required
.\gradlew.bat jpackageWindowsOutput:
- Installer:
build/installer/SecondHandTrading-1.5.4.exe - Behavior: installs to
C:\Program Files\SecondHandTradingand creates Start Menu / Desktop shortcuts
.\gradlew.bat jpackagePortableOutput directory:
build/jpackage/app-image/SecondHandTrading/
├── SecondHandTrading.exe # Main executable
├── runtime/ # Bundled runtime (Liberica JDK 21 + JavaFX)
└── item_images/ # Product images
Zip the whole SecondHandTrading directory and share it with users.
After extraction they can simply double-click SecondHandTrading.exe to run.
.\gradlew.bat fatJar -x testFor release builds, it is recommended to run the full test suite first:
.\gradlew.bat test.
Recommended distribution options:
- Windows Installer:
build/installer/SecondHandTrading-1.5.4.exe- Best for end users; one-click installation with automatic shortcuts
- Windows Portable Version:
build/jpackage/app-image/SecondHandTrading/- Best for USB / "green software" style; unzip and run
SecondHandTrading.exedirectly
- Best for USB / "green software" style; unzip and run
The system includes pre-initialized demo accounts with sample data. All accounts use the password: password123
| Username | Password | Role | Status & Description | |
|---|---|---|---|---|
| admin | password123 | ADMIN | admin@example.com | Administrator - Full system access |
| alice | password123 | SELLER | alice@example.com | Active seller - Sold 2 items (MacBook, iPhone), earned $13,598 |
| bob | password123 | SELLER | bob@example.com | Active seller - Sold 1 item (Sony headphones), earned $1,499, has 1 item for sale (Dell monitor) |
| charlie | password123 | BUYER | charlie@example.com | Active buyer - Purchased 1 item (iPhone) from Alice |
| diana | password123 | SELLER | diana@example.com | Seller/Buyer - Purchased 1 item (Sony headphones) |
| evan | password123 | BUYER | evan@example.com | Seller - Has 1 item for sale (IKEA desk) |
| frank | password123 | SELLER | frank@example.com | Active seller - Has 2 items for sale (Nikon camera, ThinkPad) |
| grace | password123 | BUYER | grace@example.com | Active buyer - Has 1 order in progress (Nintendo Switch) |
| henry | password123 | SELLER | henry@example.com | Active seller - Sold 1 item (Nintendo Switch), earned $1,899 |
| iris | password123 | BUYER | iris@example.com | Active buyer - Has favorites and product inquiries |
The database includes comprehensive demo data to showcase all platform features:
📦 Items (20 total)
- Categories: Electronics, Gaming, Furniture, Books, Sports
- Various prices ranging from $50 to $8,999
- All items include matching product images
💬 Messages (18 conversations)
- Multiple conversation threads between buyers and sellers
- Inquiries about products, price negotiations, and delivery arrangements
🛒 Orders (6 transactions)
- Various order statuses: completed, shipped, paid
- Orders include complete shipping addresses in the US
❤️ Favorites (30 items)
- Distributed across all buyer accounts
- Multiple favorites per user for testing
- On first launch, if the database is empty, the app automatically initializes demo data, including:
- 15 users (1 admin, multiple SELLER / BUYER accounts)
- 20 items
- 18 messages
- 6 orders
- 30 favorites
- All accounts use
password123by default.
Default database path:
- Windows:
C:\Users\<username>\.secondhand-trading\secondhand.db - macOS / Linux:
~/.secondhand-trading/secondhand.db
# Windows
.\gradlew.bat initDemoData
# macOS / Linux
./gradlew initDemoDataTo completely reset the database (delete all data and recreate demo data):
# Windows
Remove-Item "$env:USERPROFILE\.secondhand-trading\secondhand.db" -Force
.\gradlew.bat initDemoData
# macOS / Linux
rm ~/.secondhand-trading/secondhand.db
./gradlew initDemoDataImage Storage:
- Sample and uploaded images are stored under the
item_images/directory - The database stores image paths only, not binary image data
- For the portable build,
item_images/is packaged together with the app
Note: All accounts use password123 for easy testing. Change passwords in production environments.
- User registration and login
- Password encryption (SHA-256)
- User Profile Center:
- Avatar upload and display
- Bio and personal information editing
- Statistics (Total Sales, Total Purchases, Join Date)
- Role-based access control (Buyer/Admin)
- Post items (title, description, price, contact info)
- Image Upload: Upload and display item images
- Supported formats: JPG, PNG, GIF, BMP
- Images stored in local
item_images/folder - All users can view uploaded images
- Advanced Search: Filter by keyword, price range, category, and sort by price/date
- View item details with seller rating and item images
- Manage my items (edit/delete)
- Order Lifecycle: Purchase -> Paid -> Shipped -> Received -> Completed
- Order History: View past purchases and sales
- Review System: Rate and review sellers after transaction completion
- Add/remove items to/from favorites
- Real-time Notifications: Get alerts for order status changes (Shipped, Received)
- Notification Center to view all alerts
- Contact sellers via messages
- View inbox
- Reply to messages
- User management (view/enable/disable users)
- Item moderation
The project follows a mixed testing approach combining unit tests and integration tests:
- Location:
src/test/java/unit/ - Services tested with mocked dependencies:
ItemServiceTest(17 test cases)FavoriteServiceTest(11 test cases)ImageUtilsTest(15 test cases for image processing)ValidationUtilsTest,PasswordUtilsTest
- Location:
src/test/java/integration/ - Components tested:
- DAO Layer:
UserDaoImplTest,ItemDaoImplTest(11 search tests),MessageDaoImplTest,FavoriteDaoImplTest,OrderDaoImplTest(10 test cases) - Service Layer:
UserServiceTest,MessageServiceTest,OrderServiceTest,ReviewServiceTest(comprehensive review system tests),NotificationServiceTest - Config:
DatabaseConfigTest,DemoDataInitializerTest - Utilities:
ExportUsersTest
- DAO Layer:
Overall Coverage:
- Instruction Coverage: 92% (4,929 of 5,318 instructions)
- Branch Coverage: 80% (296 of 367 branches)
- Method Coverage: 95% (272 of 286 methods)
- Class Coverage: 100% (all 28 classes)
- Line Coverage: 91% (1,104 of 1,215 lines)
By Package:
| Package | Instruction Coverage | Branch Coverage | Methods |
|---|---|---|---|
| model | 99% | n/a | 110/110 |
| config | 94% | 75% | 18/18 |
| dao.impl | 92% | 76% | 56/56 |
| service | 90% | 80% | 79/79 |
| util | 88% | 96% | 23/23 |
Total Test Cases: 271 (all passing)
# Run all tests
.\gradlew test
# Run only unit tests
.\gradlew unitTest
# Run only integration tests
.\gradlew integrationTest
# Generate coverage report
.\gradlew jacocoTestReport
# View coverage report
# Open: build/jacocoHtml/index.html in browserCurrent Status: 271 test cases, 92% instruction coverage, 80% branch coverage
Recent Improvements (Test branch -> Master):
- Enhanced DAO Tests: Added comprehensive tests for
ItemDaoImpl.searchItems()(11 cases) andOrderDaoImpl(10 cases) - Service Integration Tests: Comprehensive testing for
ReviewService,OrderService,NotificationService - Utility Tests: Added
ImageUtilsTestwith 15 test cases for image processing - Configuration Tests:
DemoDataInitializerTestfor data initialization validation - Database Safety: Fixed critical database isolation bug preventing production data loss
Next Steps (Optional enhancements):
- Controller Integration Tests: Add tests for UI Controllers with mocked Services (~30-50 cases)
- Edge Case Coverage: Improve branch coverage in complex error handling scenarios
Target: Maintain 90%+ coverage with continued refactoring
The project uses SQLite database with the file secondhand.db, containing the following tables:
users- User table (updated with avatar, bio, stats)items- Item tablefavorites- Favorites tablemessages- Messages tableorders- Order transaction recordsreviews- User ratings and reviewsnotifications- System notifications
The database is automatically created on first run. Schema migrations are handled automatically.
Run the following utility class to view all users and their information:
# View all users with password hashes and roles
java -cp "build/classes/java/main;lib/*" util.QueryUsers
# Or run directly in IDE: src/util/QueryUsers.javaExport all user information to a text file:
# Export users to users_export.txt
java -cp "build/classes/java/main;lib/*" util.ExportUsers
# Or run directly in IDE: src/util/ExportUsers.javaProblem: Java is not installed or not in system PATH.
Solution:
# Check if Java is installed
java -version
# If not found, install Java 21:
# Windows: Download from https://adoptium.net/temurin/releases/?version=21
# macOS: brew install openjdk@21
# Linux: sudo apt install openjdk-21-jdkProblem: Running with wrong Java version or missing JavaFX.
Solution: Use the portable package with the Launcher:
# Download the portable package and run
cd SecondHandTrading
java -cp ".;3343-Project.jar" LauncherOr use Start.bat which handles this automatically.
Note: You may see a warning Unsupported JavaFX configuration: classes were loaded from 'unnamed module'. This is expected and does not affect functionality.
Problem: Build directory is locked by another process (IDE, OneDrive sync, etc.)
Solution:
# Windows PowerShell
.\gradlew.bat --stop
Remove-Item -Recurse -Force .\build
.\gradlew.bat fatJar
# macOS/Linux
./gradlew --stop
rm -rf build
./gradlew fatJarProblem: Network issues downloading Gradle wrapper.
Solution:
- Check your internet connection
- Try using a VPN
- Or use locally installed Gradle:
gradle fatJar
Problem: The item_images/ folder is missing or not in the correct location.
Solution: Ensure item_images/ folder is in the same directory as the JAR file:
your-folder/
├── 3343-Project-1.0-SNAPSHOT-all.jar
├── secondhand.db
└── item_images/
├── bike.jpg
├── laptop.jpg
└── ...
Problem: Database file is corrupted or locked.
Solution:
# Delete the database and reinitialize
# Windows
Remove-Item secondhand.db -Force
.\gradlew.bat initDemoData
# macOS/Linux
rm secondhand.db
./gradlew initDemoDataProblem: System encoding mismatch.
Solution: Run with UTF-8 encoding:
java -Dfile.encoding=UTF-8 -jar build/libs/3343-Project-1.0-SNAPSHOT-all.jarIssues and Pull Requests are welcome!
- Fork the project
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/your-feature) - Create a Pull Request
This project is for educational purposes only.
- Project: CS3343 Group 11
- Repository: https://github.com/fql9/3343-Project
Note: This project is a course assignment of CS3343 and should not be used for commercial purposes.