This guide will help you set up and run the Online Quiz System on your local machine.
Before you begin, ensure you have the following installed:
-
Java Development Kit (JDK) 17 or higher
- Download: https://www.oracle.com/java/technologies/downloads/
- Verify installation:
java -version javac -version
-
Apache Maven 3.6 or higher
- Download: https://maven.apache.org/download.cgi
- Verify installation:
mvn -version
-
Git (optional, for version control)
- Download: https://git-scm.com/downloads
- IDE: IntelliJ IDEA, Eclipse, or VS Code
- Terminal: PowerShell, Command Prompt, or Git Bash
- Web Browser: Chrome, Firefox, or Edge
cd "e:\MCQ spring"mvn clean installThis command will:
- Download all dependencies
- Compile the source code
- Run tests (if any)
- Package the application into a JAR file
Expected Output:
[INFO] BUILD SUCCESS
[INFO] Total time: XX.XXX s
Check if the JAR file was created:
dir target\online-quiz-system-1.0.0.jarStart the Server:
mvn spring-boot:runThe server will start and display:
===========================================
Quiz Server Started on Port: 5000
Waiting for clients to connect...
===========================================
Start the Server:
java -jar target\online-quiz-system-1.0.0.jar- Open your web browser
- Navigate to: http://localhost:8080
- You should see the Quiz System dashboard
You need at least 2 clients to start a quiz.
Open multiple Command Prompt/PowerShell windows:
Terminal 1 (Client 1):
cd "e:\MCQ spring"
java -cp target\online-quiz-system-1.0.0.jar com.quiz.client.QuizClientTerminal 2 (Client 2):
cd "e:\MCQ spring"
java -cp target\online-quiz-system-1.0.0.jar com.quiz.client.QuizClientTerminal 3 (Client 3) - Optional:
cd "e:\MCQ spring"
java -cp target\online-quiz-system-1.0.0.jar com.quiz.client.QuizClientOpen multiple terminal windows:
cd "e:/MCQ spring"
java -cp target/online-quiz-system-1.0.0.jar com.quiz.client.QuizClient-
Start the Server
mvn spring-boot:run
Wait for: "Quiz Server Started on Port: 5000"
-
Open Web Dashboard (Optional)
- Browser: http://localhost:8080
- Monitor server status and leaderboard
-
Start Client 1
java -cp target\online-quiz-system-1.0.0.jar com.quiz.client.QuizClient- Enter name when prompted
-
Start Client 2
java -cp target\online-quiz-system-1.0.0.jar com.quiz.client.QuizClient- Enter name when prompted
-
Quiz Starts Automatically
- Server detects 2+ players and begins
- Answer questions as they appear
-
View Results
- Final scores displayed in console
- UDP broadcast received by all clients
- Web dashboard shows leaderboard
After setup, verify the following:
- Server starts without errors
- Web interface loads at http://localhost:8080
- Server status shows "RUNNING"
- TCP Port shows 5000
- UDP Port shows 5001
- Clients can connect successfully
- Questions are displayed correctly
- Scores update properly
- Final results are broadcast via UDP
Solution:
# Windows - Find process using port 8080
netstat -ano | findstr :8080
taskkill /PID <process_id> /F
# Find process using port 5000
netstat -ano | findstr :5000
taskkill /PID <process_id> /FSolution:
- Verify Java is installed:
java -version - Add Java to PATH environment variable
- Restart terminal after installation
Solution:
- Verify Maven is installed:
mvn -version - Add Maven to PATH environment variable
- Restart terminal after installation
Solution:
- Ensure server is running
- Check if firewall is blocking ports 5000/5001
- Verify server address in QuizClient.java (should be "localhost")
Solution:
# Clean and rebuild
mvn clean
mvn install -U
# Skip tests if needed
mvn clean install -DskipTestsSolution:
- Check network configuration
- Disable firewall temporarily for testing
- Ensure UDP port 5001 is not blocked
- Try running all clients on localhost
Edit src/main/resources/application.properties:
# HTTP Server Port
server.port=8080
# TCP Socket Port
quiz.server.tcp.port=5000
# UDP Broadcast Port
quiz.server.udp.port=5001
# Maximum Clients
quiz.server.max.clients=10Edit src/main/java/com/quiz/client/QuizClient.java:
private static final String SERVER_HOST = "localhost";
private static final int SERVER_PORT = 5000;
private static final int UDP_PORT = 5001;After changes, rebuild:
mvn clean installcurl http://localhost:8080/api/quiz/infoExpected Response:
{
"tcpPort": 5000,
"udpPort": 5001,
"status": "running",
"activePlayers": 0
}curl http://localhost:8080/api/quiz/leaderboardExpected Response:
[](Empty array when no players)
- Start server
- Connect 2 clients
- Complete quiz
- Verify final results in all consoles
- README.md - Full project documentation
- Source Code - Well-commented code in
src/main/java/com/quiz/ - Web UI - Interactive dashboard at http://localhost:8080
-
Use IDE for easier development
- Import as Maven project
- Use built-in run configurations
-
Enable hot reload
- Spring Boot DevTools is included
- Changes auto-reload during development
-
View logs
- Server logs show all activity
- Client logs show connection status
-
Test with multiple terminals
- Use split terminal in VS Code
- Or use Windows Terminal with multiple tabs
When presenting to your instructor:
-
Show Architecture Diagram (in README.md)
-
Demonstrate Each Concept:
- TCP Socket: Show connection establishment
- Multithreading: Show multiple clients connecting
- Synchronization: Show score updates
- UDP: Show broadcast reception
- Client-Server: Show message exchange
-
Show Code Highlights:
- Point out synchronized methods
- Show thread pool creation
- Demonstrate UDP broadcasting
-
Run Live Demo:
- Start server
- Connect 3-5 clients
- Complete a quiz
- Show final results
Your setup is successful when:
โ
Server starts without errors
โ
Web dashboard is accessible
โ
Multiple clients can connect
โ
Quiz runs smoothly
โ
Scores are tracked correctly
โ
UDP broadcast is received
โ
All network concepts are demonstrated
Need Help? Check the troubleshooting section or contact your team members!