Install java, set the JAVA_HOME to the java installation path and
PATH variable to existing PATH + %JAVA_HOME%\bin folder.
Install MAVEN and set MAVEN_HOME to the maven installation path and
PATH variable to existing PATH + %MAVEN_HOME%\bin folder.
If I want to create a java program, compile and run it following are the steps I will do.
(BASE_FOLDER)/com/example
App.java
package com.example;
public class App {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
On the command prompt, In BASE_FOLDER compile the App.java as below
javac com/example/App.java
Run the App.java file as below
Hello, World!
But when I have a whole project will hundreds of .java files, dependent jar files and libraries, compiling the individual files and specifying the classpath for the various dependent objects becomes unmanageable. Tools such as Ant, Make and Maven are specifically for this purpose.
Apache Maven is a build tool for java projects. Using a project object model (POM), Maven manages a projects compilation, testing and documentation. It is developed by the Apache Software Foundation. (https://maven.apache.org/). It automates the process of compiling code, managing external dependencies, running tests and packaging applications into distributable formats like JAR or WAR files. It operates on the principle of "Convention over Configuration," meaning it provides standard layouts and lifecycles so you only specify exceptions.
The Core Blueprint: POM (pom.xml)
Every Maven project is driven by a
pom.xml (Project Object Model) file located at the root directory. It holds the project's configurations, identity, and required plugins. [
1,
2]
- Project Coordinates: Every project defines its unique identity via three core coordinates:
groupId: The organization or company domain name (e.g., com.example).artifactId: The unique name of the project or module (e.g., my-app).version: The current version of the project (e.g., 1.0.0-SNAPSHOT). [1, 2, 3]
- Super POM: If a configuration is missing, Maven inherits default settings from a global "Super POM," which automatically maps standard directories and sets Maven Central as the default remote repository. [1, 2, 3, 4]
Automated Dependency Management
Maven eliminates the hassle of manually downloading and tracking third-party
.jar files. [
1]
- Transitive Dependencies: When you add a library (e.g., Spring Boot), Maven automatically analyzes that library's dependencies and downloads them as well, preventing version conflicts. [1, 2]
- The Layered Repository System:
- Local Repository: A hidden folder on your machine (
~/.m2/repository) that caches downloaded files to speed up subsequent builds. - Central Repository: An online community-maintained library where thousands of open-source components live.
- Remote Repository: Private or company-internal servers used to host proprietary artifacts or proxy external traffic. [1, 2]
Standard Directory Structure
Maven dictates a specific structure out of the box, ensuring that any developer stepping into the project instantly knows where files live. [
1,
2]
src/main/java: Houses the production Java source code.src/main/resources: Contains configuration files, properties, and static assets.src/test/java: Dedicated to test frameworks like JUnit or TestNG classes.target/: The output directory where compiled .class files and final packaged binaries are generated. [1, 2, 3, 4, 5]
The Build Lifecycle and Phases
Maven functions through a sequence of steps known as
Build Phases. When you execute a phase, Maven automatically runs every preceding phase in that sequence. [
1,
2,
3]
The primary default lifecycle includes: [
1,
2,
3,
4]
validate: Assures that the project structure is correct and all information is available.compile: Converts Java source code into bytecode (.class files).test: Runs unit tests within the project.package: Packages the compiled code into a distributable format (like a .jar).verify: Runs integration tests to ensure quality criteria are met.install: Pushes the package into your local .m2 repository so other local projects can use it.deploy: Pushes the final package to a remote repository to share with the production team or community. [1, 2, 3, 4, 5]
Commonly combined commands include mvn clean install, which wipes the target/ directory (clean lifecycle) and rebuilds/installs the application from scratch.
Below is an example for creating a MAVEN pom.xml file to compile and run App.java with a brief explanation for each of the maven tags.
<project xmlns="http://apache.org" xmlns:xsi="http://w3.org"
xsi:schemaLocation="http://apache.org http://apache.org">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>myapp1</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<mainClass>com.example.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
The Root and Metadata Elements
<project xmlns="http://apache.org" xmlns:xsi="http://w3.org" xsi:schemaLocation="http://apache.org http://apache.org">
<project>: The root tag that encloses the entire Maven configuration.xmlns and xsi: These tell your code editor and Maven where to find the rules (schemas) for validating the XML structure. <modelVersion>4.0.0</modelVersion>
<modelVersion>: Defines the version of the POM structure layout. Version 4.0.0 is the mandatory standard for Maven 2 and Maven 3.
Project Coordinates (The GAV)
These three elements uniquely identify your project across the Java ecosystem.
<groupId>com.example</groupId>
<groupId>: The organization or package name. It usually follows reverse domain name rules (like com.companyname).
<artifactId>myapp1</artifactId>
<artifactId>: The specific name of your project. This becomes the actual name of your compiled JAR file.
<version>1.0-SNAPSHOT</version>
<version>: The current version of your app. -SNAPSHOT means it is a work-in-progress development version.
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<properties>: A section used to define variables or settings.source: Tells Maven your source code is written using Java 17 features.target: Tells Maven to compile bytecode that is fully compatible with Java 17 runtimes.<build>: Contains configurations that manage how your project compiles, runs, and bundles.<plugins>: A wrapper tag holding the list of external tools/extensions Maven will use. <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<plugin>: Declares an external tool to use.groupId & artifactId: Points Maven to download the official plugin that can execute Java programs.version: Locks down the version of the plugin so your build remains stable over time.
<configuration>
<mainClass>com.example.App</mainClass>
</configuration>
<configuration>: Passes custom settings directly to the plugin.<mainClass>: Tells the plugin exactly where your public static void main method lives so it knows what to run.
We can now build and run the App.java using maven on command line as follows
D:\java\HelloWorld\myapp1>mvn exec:java
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.example:myapp1 >-------------------------
[INFO] Building myapp1 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- exec:3.1.0:java (default-cli) @ myapp1 ---
Hello, World!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.287 s
[INFO] Finished at: 2026-07-20T18:12:01+05:30
[INFO] ------------------------------------------------------------------------
See what below command does
mvn archetype:generate -DgroupId=com.example -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
The command creates a new Java project template using Apache Maven. It generates a standardized folder structure and a baseline pom.xml configuration file so that you can start your development work immediately without have to create directories and folder structure manually.
God's for the day
The temptations of commerce
A merchant can hardly keep from wrongdoing,
nor is a tradesman innocent of sin.
Many have committed sin for gain.
And those who seek to get rich will avert their eyes.
As a stake is driven firmly into a fissure between stones,
so sin is wedged in between selling and buying.
If a person is not steadfast in the fear of the Lord,
His house will be quickly overthrown.
Sirach 26:1-4
Gospel teachings of Jesus
Reproving another who sins
If another member of the church sins against you,
go and point out the fault when the two of you are alone.
If the member listens to you, you have regained that one.
But if you are not listened to, take one or two others
along with you, so that every word may be confirmed
by the evidence of two or three witnesses. If the member
refuses to listen to them, tell it to the church; and if the
offender refuses to listen even to the church, let such a
one be to you as a gentile and a tax collector. Truly I tell
you whatever you bind on Earth, will be bound in heaven,
and whatever you loose on Earth will be loosed in heaven.
Again, truly I tell you, if two of you agree about anything
you ask, it will be done for you by my Father in Heaven.
For where two or three are gathered in my name, I am
there among them.
Mathew 18:15-20