Welcome! Type "help" for available commands.
$
Loading terminal interface...
Back to Blog

Java, Maven, & Gradle: OS Setup & Project-Level Usage

May 17, 2025
William Callahan

Software engineer and founder with a background in finance and tech. Currently building aVenture.vc, a platform for researching private companies. Based in San Francisco.

javajdkmavengradlebuild-toolssdkmanjenvmaven-wrappergradle-wrapper
Java, Maven, & Gradle: OS Setup & Project-Level Usage

Related Java Setup Guides

  • This Article: Core Java, Maven & Gradle Setup & Usage
  • Specifics: Setting up JavaFX
  • Specifics: Setting up a Spring Boot Server

Part 1: OS-Level Tool Installation (The Foundation)

For project setups, you'll need a Java Development Kit (JDK) installed on your system. Optionally, you might install Maven and/or Gradle globally, though for most project work, their respective project-level wrappers (mvnw, gradlew) are also used.

Toggle dropdownInstalling a Java Development Kit (JDK)

The JDK is essential for compiling and running Java applications. It includes the Java Runtime Environment (JRE) and development tools like the Java compiler (javac).

Toggle dropdownInstalling Build Tools (Maven & Gradle) - OS Level (Optional)

While project wrappers (mvnw, gradlew) are preferred for project work, you might want global installations for bootstrapping new projects or for tools that expect them.

OS Install vs. Project Wrappers

Global (OS-level) installations of Maven/Gradle are for convenience or bootstrapping. For actual project development and builds, always prefer using the project's Maven Wrapper (./mvnw) or Gradle Wrapper (./gradlew). This ensures everyone uses the same build tool version, leading to reproducible builds. The wrappers will download the correct version if needed.

Part 2: Project-Specific Java Versioning

Ensure different projects can use different Java versions without conflict.

Toggle dropdownProject-Specific JAVA_HOME (Manual/Scripted)
Toggle dropdownIDE Project JDK Settings

Note

IDE settings control development. CLI consistency benefits from scripted JAVA_HOME or tools like SDKMAN!.

Part 3: Maven - Project Versioning & Common Commands

Maven is a build tool that uses a Project Object Model (POM) file (pom.xml) to manage a project's build, reporting, and documentation. Use the Maven Wrapper (mvnw) to pin the Maven version per project.

Toggle dropdownUnderstanding the Maven Wrapper

The Maven Wrapper (mvnw for Unix-like systems, mvnw.cmd for Windows) ensures that a project uses a consistent version of Maven without requiring a global installation. It downloads the specified Maven version if it's not already available.

Why use it? Reproducible builds across different developer machines and CI/CD environments.
Toggle dropdownAdding or Updating the Wrapper
If your project (often from Spring Initializr) doesn't include it, or to update the version:
# In project root, using a globally installed mvn (if available)
mvn -N io.takari:maven:wrapper -Dmaven=3.9.6 # Specify desired Maven version
This creates/updates .mvn/wrapper/maven-wrapper.properties, which specifies the Maven version to use.
# .mvn/wrapper/maven-wrapper.properties
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
# ... other properties
Toggle dropdownCore Maven Lifecycle & Commands (using ./mvnw)
Always use ./mvnw (or mvnw.cmd) instead of a global mvn for project tasks.
Toggle dropdownMaven Wrapper & Java Version
The pom.xml defines Java compatibility for compilation:
<!-- pom.xml -->
<properties>
    <java.version>17</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source>
    <maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
Ensure the active JAVA_HOME (ideally set per-project) is compatible with these settings.

Part 4: Gradle - Project Versioning & Common Commands

Gradle is another popular build automation tool, known for its flexibility and performance, especially with Groovy or Kotlin for build scripts (build.gradle or build.gradle.kts). The Gradle Wrapper (gradlew) is essential.

Toggle dropdownUnderstanding the Gradle Wrapper

The Gradle Wrapper (gradlew for Unix-like systems, gradlew.bat for Windows) allows a project to build with a specific version of Gradle without requiring a global Gradle installation. It downloads the declared Gradle version if necessary.

Why use it? Ensures build consistency and reproducibility.
Toggle dropdownAdding or Configuring the Wrapper
Most projects initialized with Gradle (e.g., via Spring Initializr) include the wrapper. To add or change the Gradle version it uses (if you have a global gradle installed):
# In project root
gradle wrapper --gradle-version 8.7 # Specify desired Gradle version
The wrapper configuration, including the Gradle distribution URL, is in gradle/wrapper/gradle-wrapper.properties.
# gradle/wrapper/gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-8.7-bin.zip
# ... other properties
Toggle dropdownCore Gradle Tasks & Commands (using ./gradlew)
Always use ./gradlew (or gradlew.bat) for project tasks.
Toggle dropdownGradle Wrapper & Java Version
The build.gradle (Groovy) or build.gradle.kts (Kotlin) file defines Java compatibility:
// build.gradle (Groovy DSL)
java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}
Ensure the active JAVA_HOME is compatible. Gradle also supports Java toolchains for more fine-grained control over the JDK/JRE used by Gradle tasks, independent of JAVA_HOME.

Part 5: Managing & Updating Dependencies

Dependencies are external libraries your project relies on. They are declared in pom.xml (Maven) or build.gradle(.kts) (Gradle).

Toggle dropdownDependency Declaration & Update Commands

IDE Support

IntelliJ IDEA and VS Code (with Java extensions) often provide UI features to detect and update dependencies.

Similar Content

Home
CV
ExperienceEducation
ProjectsBookmarksInvestmentsContactBlog
Welcome! Type "help" for available commands.
$
Loading terminal interface...

Similar Content

Related Articles

April 8, 2025
How to setup the Java SDK and use JavaFX with macOS/Windows

How to setup the Java SDK and use JavaFX with macOS/Windows

A modern guide to setting up Java development with JavaFX on macOS and Windows using IntelliJ IDEA or VS Code. While setting `JAVA_HOME` is still usef...

macosjavazshintellijenvironment variablesjavafx+9
BLOG
May 12, 2025
Setting Up a Modern Spring Boot Web Server with REST API & Web Content (2025 Guide)

Setting Up a Modern Spring Boot Web Server with REST API & Web Content (2025 Guide)

How to create a Spring Boot application with RESTful APIs and static web content using Maven and IntelliJ IDEA in modern Java.

spring bootjavamavenintellij idearest apiweb development+10
BLOG

Related Bookmarks

github.com
September 14, 2025
GitHub - ChangeNode/spring-boot-supabase: Modern Java web application starter template.

GitHub - ChangeNode/spring-boot-supabase: Modern Java web application starter template.

Modern Java web application starter template. Contribute to ChangeNode/spring-boot-supabase development by creating an account on GitHub.

authentication solutionsgithub projectssupabase integrationsspring boot startersfull stack java applicationschangenode+7
LINK
github.com
January 29, 2026
GitHub - jmuncor/sherlock: Intercept LLM API traffic and visualize token usage in a real-time terminal dashboard. Track costs, debug prompts, and monitor context window usage across your AI development sessions.

GitHub - jmuncor/sherlock: Intercept LLM API traffic and visualize token usage in a real-time terminal dashboard. Track costs, debug prompts, and monitor context window usage across your AI development sessions.

Intercept LLM API traffic and visualize token usage in a real-time terminal dashboard. Track costs, debug prompts, and monitor context window usage ac...

llm toolstoken trackingai dashboardsprompt debuggingcli proxiesusage+7
LINK

Related Projects

Apple Maps Java SDK

Apple Maps Java SDK

Java SDK for Apple Maps Server API — geocoding, search, directions

javasdkapple mapsgeocodingrest apiopen source+11
PRJ
TUI4J

TUI4J

Terminal UI framework for Java — a port of BubbleTea from Go

terminal uituijavaopen sourcedeveloper toolsframework+11
PRJ

Related Books

December 31, 2025
Build a Reasoning Model (From Scratch)

Build a Reasoning Model (From Scratch)

Sebastian Raschka

LLM reasoning models have the power to tackle truly challenging problems that require finding the right path through multiple steps. In this book you’...

computerssebastian raschkasimon and schustermodelbuildreasoning+5
BOOK
Spring AI in Action

Spring AI in Action

Craig Walls

Use Spring AI to add generative AI features like virtual assistants, text summaries, and suggestions to your Java applications. No matter what kind of...

computerscraig wallssimon and schusterspringactionfeatures+5
BOOK
Build AI Applications with Spring AI

Build AI Applications with Spring AI

Fu Cheng

fu chengspringbuildapplications
BOOK

Related Investments

Polly

Polly

aVenture

Polly is a modern employee feedback and engagement platform.

enterpriseseries a+activepollyplatformmodern+3
INV
Heroes Jobs

Heroes Jobs

The app for Gen Z searching for a job

hr & recruitingseed+realizedheroesjobsapp+3
INV
Title Labs

Title Labs

Blockchain-based platform for real estate title and property rights management.

blockchain / cryptopre-seedactivetitlelabsplatform+5
INV