Sitemap
DoğukanTechBlog

DoğukanTechBlog

I’m a software engineer with a strong passion for Spring Boot and scalable distributed architectures.

What are Java modules

2 min readJul 24, 2025

We will learn about java modules.

What are Java Modules?

The Module System (JPMS), introduced with Java 9, aimed to improve the manageability, security, and performance of large applications.

How to generate a (module📦) in java ?

Right click to your <project-name>/New/Module

📦 Why Use Modules?

  • Encapsulation: You can hide internal packages and expose only what’s necessary.
  • Reliable Dependencies: Ensures your module explicitly declares what it needs.
  • Faster Startup: JVM can optimize startup with modular applications.
  • Security: Limits access to internal APIs, reducing unintended usage.
  • Better Maintainability: Encourages cleaner architecture with clear boundaries.

How to manage multi-module projects with Gradle ?

First of all we have to add our module names to settings.gradle file

rootProject.name = 'MyProject'
include 'models', 'repository', 'services', 'security', 'controllers', 'utils'

If we are using modules as a dependency in any other modules , we have to implemet these amazing keywords.

Get DoğukanTechBlog’s stories in your inbox

Join Medium for free to get updates from this writer.

for instance , if we will use models , repository and utils.

dependencies {
implementation project(":models")
implementation project(":repository")
implementation project(":utils")
...
}

You have to watch out naming conventions.

You can load dependencies with this command

./gradlew clean build --refresh-dependencies

Summary

We can make our project cleaner, robust and manageable by using java modules.

Step 1 : Add a new module

Step 2 : Add module name to settings.gradle

Step 3 : If needed add module as a dependency

Step 4 : Run it

Thanks for reading.

--

--

DoğukanTechBlog
DoğukanTechBlog

Written by DoğukanTechBlog

0 followers

I’m a software engineer with a strong passion for Spring Boot and scalable distributed architectures.