Absolutely. Here’s a simple Java + Maven setup and a first Hello World project.
1. Install Java
Install JDK 17 or newer. I recommend JDK 21 for a modern Maven project.
Verify:
java -version
javac -version
You should see something like:
java version "21.x.x"
javac 21.x.x
Also set JAVA_HOME if your OS/tooling needs it.
2. Install Maven
Verify Maven:
mvn -version
You should see something like:
Apache Maven 3.x.x
Java version: 21.x.x
If mvn isn’t recognized, Maven needs to be installed and its bin directory added to your PATH.
3. Create a Maven project
You can create the basic project structure manually:
hello-world/
├── pom.xml
└── src/
└── main/
└── java/
└── com/
└── example/
└── App.java
Create pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>hello-world</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
</properties>
</project>
Create App.java:
package com.example;
public class App {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
4. Build the project
From the hello-world directory:
mvn clean package
You should eventually see:
BUILD SUCCESS
Maven will create:
target/
└── hello-world-1.0-SNAPSHOT.jar
5. Run Hello World
The easiest way initially is:
java -cp target/classes com.example.App
Output:
Hello, World!
6. Maven’s important commands
mvn clean # Remove previous build files
mvn compile # Compile Java source
mvn test # Run tests
mvn package # Build JAR
mvn clean package
The key idea is:
pom.xml
↓
Maven configuration + dependencies
↓
src/main/java
↓
Java source code
↓
mvn package
↓
target/
↓
JAR
If you’re on Windows, I can also give you the exact JDK + Maven + IntelliJ IDEA setup, including environment variables and creating the project from the Maven archetype.