-
Check if Maven is already installed:
Open Command Prompt or PowerShell and run:
mvn -v
-
Download Maven:
- Go to https://maven.apache.org/download.cgi
- Download the latest binary ZIP archive.
-
Extract Maven:
-
For example, extract to:
C:\Program Files\apache-maven-3.9.5
-
-
Add Maven to your system PATH:
-
Add the
bindirectory to PATH:C:\Program Files\apache-maven-3.9.5\bin
-
-
Verify installation:
mvn -v
You should see Maven version and Java version info.
- All project dependencies are listed in
pom.xml. - Do not manually download JAR files. Maven handles them automatically.
-
Open
pom.xml. -
Add the dependency inside the
<dependencies>section:<dependency> <groupId>org.example</groupId> <artifactId>example-lib</artifactId> <version>1.2.3</version> </dependency>
-
Fetch the dependency using:
mvn compile
-
To view all dependencies and their hierarchy:
mvn dependency:tree
Goal: Edit Java code and run it directly in Tomcat without creating a WAR.
-
Open Command Prompt or PowerShell and navigate to the project folder:
cd C:\tomcat\webapps\trivia-app -
Compile the code and download dependencies:
mvn compile # OR: mvn clean compile # to ensure old compiled files are gone
-
Compiled
.classfiles will be placed in:WEB-INF\classes\
-
-
Start Tomcat:
cd C:\tomcat\bin startup.bat -
Edit code in
src\main\java\as needed. -
Re-run:
cd C:\tomcat\webapps\trivia-app mvn compile # OR: mvn clean compile # to ensure old compiled files are gone -
Restart Tomcat to see changes:
cd C:\tomcat\bin shutdown.bat startup.bat
Goal: Build a clean WAR file and deploy it for hosting.
-
Build the WAR:
cd C:\tomcat\webapps\trivia-app mvn clean package-
The WAR file will be located at:
target\trivia-app.war
-
-
Deploy the WAR to Tomcat:
copy target\trivia-app.war C:\tomcat\webapps\- Do not place the WAR inside
WEB-INF\classes\. - Tomcat will automatically unpack it and use its internal
WEB-INF\classes\.
- Do not place the WAR inside
-
Start or restart Tomcat:
cd C:\tomcat\bin shutdown.bat startup.bat -
Access the app:
http://localhost:8080/trivia-app
| Environment | Command | What Happens |
|---|---|---|
| Local Dev | mvn compile OR mvn clean compile |
Compiles .class files into WEB-INF\classes\ for Tomcat to use |
| Production | mvn clean package |
Generates trivia-app.war in target\ ready to deploy |
- Local edits → compile → restart Tomcat (local dev)
- Production deploy → build WAR → copy WAR → restart Tomcat (for hosting)
trivia-app/ ← project root (Tomcat webapp root for local dev, place this in your tomcat webapps folder)
├── WEB-INF/ ← What tomcat actually understands (Ex: if you are trying to find html files route according to here)
│ ├── web.xml ← servlet configuration, BE team put your URL mappings here
│ ├── classes/com/triviaapp/servlets/ ← (can ignore) compiled .class files go here after mvn compile
│ │ ├── CreateQuizServlet.class (for example)
│ └── lib/ ← (can ignore) runtime JAR dependencies copied here by Maven
│
├── src/
│ └── main/
│ └── java/
│ └── com/
│ └── triviaapp/ ← Other files can go in new folders from triviaapp folder
│ └── servlets/ ← BE servlets
│ ├── CreateQuizServlet.java
│ └── OtherServlet.java
│
├── src/main/webapp/ ← IMPORTANT: FE files go here (otherwise they will be git-ignored. This is required.)
│ ├── index.html
│ ├── styles.css
│ └── scripts.js
│
├── pom.xml ← Maven project file (for dependencies and project build)
└── README.md
Place a .env file in the project root (do NOT commit).
Replace username and password with your actual database credentials.
JDBC_URL=jdbc:mysql://shuttle.proxy.rlwy.net:24339/trivia_app?useSSL=true&serverTimezone=UTC
JDBC_USER=your_username
JDBC_PASS=your_password