Real Java projects rarely use single-file javac. Maven and Gradle manage dependencies, directory layout, tests, and packaging into JARs/WARs.
Maven coordinates
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.2.0</version>
</dependency>
Common commands
- Maven:
mvn test,mvn package - Gradle:
./gradlew test,./gradlew build
Playground simulation
Below prints typical build output concepts—locally you need JDK + Maven/Gradle installed.
Important interview questions and answers
- Q: pom.xml vs build.gradle?
A: Maven XML declarative model; Gradle Groovy/Kotlin DSL with flexible task graph—both resolve from Maven Central. - Q: What is a fat JAR?
A: Executable JAR bundling dependencies—Spring Boot repackage goal.
Self-check
- What file declares Maven dependencies?
- Why commit lockfiles or wrapper jars?