Using NetBeans to create a Maven multi-module project
NetBeans has long been a reliable choice for Java developers who value a complete, batteries-included environment. While many younger developers in Sydney and Melbourne now reach for IntelliJ first, NetBeans still holds a strong following among teams who appreciate its free, open-source nature and tight integration with Maven.
A multi-module Maven project lets you split a large codebase into smaller, focused pieces that share a common parent configuration. For Australian software houses juggling enterprise clients from Brisbane to Perth, this approach keeps build times manageable and lets distributed teams work on different features simultaneously without stepping on each other's toes.
Before diving in, make sure your NetBeans installation bundles the Maven plugin, which it has done by default for several releases. You will also want a working JDK 17 or 21, and a stable internet connection, especially if you are working from a regional area where the NBN can occasionally be a touch temperamental.
The following walkthrough assumes you have created a basic Maven project before, but you do not need prior experience with multi-module setups. Each step builds on the previous one, so you can follow along from your home office or a coworking space in the CBD and end up with a working build by the end of the session.
Setting up the parent project
Start NetBeans and choose File > New Project. Select Maven in the categories list, then pick Java with Maven from the project options. When prompted for a name, choose something meaningful like acme-platform rather than the default NewProject1, which is a habit worth breaking early.
In the wizard, ensure you tick Create from Archetype and select maven-archetype-quickstart. This gives you a minimal structure that is easy to extend later. Once the project opens in your workspace, switch to the Files view so you can see the actual folder structure rather than the logical project view, which can hide important configuration files.
Right-click the project node and select Properties to review the settings. Under the Sources tab, set your source and target to a recent JDK version. Under the Build/Run category, confirm that the actions you plan to use match what you have defined, since mismatched goals are a common source of frustration when you first start building from the command line.
Configuring the parent POM
Open the pom.xml file in the root of your new project. NetBeans provides a handy editor with tabs for the raw XML and a more readable form view, so switch between them as you need. Add a packaging element set to pom, which tells Maven this project is a container rather than something that produces a JAR directly.
Inside the properties block, define versions for your compiler source and target, and add any shared variables like a project version or organisation name. Australian developers often use com.au.<company> as their groupId, which keeps things tidy if you ever package your libraries for distribution through a local Maven repository hosted behind the corporate firewall.
You will also need a modules section listing the child modules you plan to create. This block can be edited manually, or you can right-click the project and choose Add Module later, which updates this section for you.
Creating child modules
Once the parent is configured, right-click the Modules folder in the Projects window and select Add Module. NetBeans walks you through the same archetype selection as before, but this time the new project is nested inside the parent. Give the module a name that reflects its responsibility, such as acme-platform-api or acme-platform-web.
| Module type | Packaging | Typical contents | Used for |
|---|---|---|---|
| Web application | war | Servlets, REST endpoints, JSPs | HTTP-facing services |
| EJB module | ejb | Session beans, message-driven beans | Business logic on Jakarta EE |
| Utility library | jar | Helpers, DTOs, constants | Shared code across modules |
| Domain model | jar | Entities, value objects, repositories | Core data structures |
For modules that hold business logic, you might want to investigate how a stateful session bean fits into your application, especially if you are building something that runs on a Jakarta EE server. The flexibility of Maven lets you mix web modules, EJB modules and plain utility JARs within the same parent.
Repeat the process for each module your project requires. The Projects window shows a tree that mirrors your file system, so you can see at a glance which classes belong to which module. This visual grouping is one of the reasons NetBeans remains popular in university courses across Australian campuses.
Naming conventions for child modules
- Pick a short prefix shared across all modules, such as the project name.
- Use hyphens to separate words so the artifactId reads cleanly in dependency listings.
- Avoid version numbers or dates in the artifact name, since the parent POM holds the version.
- Match the package layout to the module name so classes are easy to locate later.
- Document each module's purpose in a short README inside its root folder.
Managing dependencies between modules
When one module needs code from another, you do not need to publish anything to a remote repository first. Simply open the receiving module's pom.xml and add a dependency, using the other module's artifactId and groupId. NetBeans resolves inter-module references automatically because the parent pom groups them together.
For cross-module testing, the surefire plugin will run unit tests in each module during the build. If you have integration tests that need the full application, consider adding the failsafe plugin to the parent so the goals are coordinated across the whole reactor. Many Australian teams schedule these longer builds to run overnight in AEST, which lines up nicely with deployments before the European trading day starts.
Watch out for circular dependencies, which Maven will refuse to build. A quick way to spot them in NetBeans is to right-click a module and choose Show Dependencies, which renders a graph of which modules depend on which.
Habits that keep multi-module projects healthy
- Run Build with Dependencies from the parent project at least once a day.
- Keep utility modules lean so they do not pull in heavy frameworks.
- Use a BOM module to pin versions shared across children.
- Set up a parent CI job that builds the whole reactor, not just single modules.
- Refactor aggressively when a module grows past a few dozen classes.
Building and deploying the project
With everything wired up, right-click the parent project and choose Build. NetBeans runs Maven through the reactor, building each module in dependency order and reporting results in the Output window. If you have a large project, this is where you will appreciate having excluded test modules you are not actively working on, since they can add minutes to every rebuild.
For deployment, package the modules your runtime needs and copy the resulting artifacts to your server. If you use a continuous integration tool such as Jenkins hosted on a local machine, point it at the parent pom and let Maven figure out the rest.
If you need to navigate back to a different topic later, the blog project categories page keeps everything organised for quick browsing.