Setting up a Java EE project with Maven in NetBeans using archetypes

Maven archetypes give Java developers a fast track to a consistent project structure, and NetBeans offers solid integration with the archetype system. When combined with the Java EE specifications, this pairing lets you skip the tedious boilerplate work and focus on the actual business logic. Many developers in Sydney and Melbourne use this approach daily to keep their enterprise code aligned with team standards.

Before you begin, you should have the Java Development Kit installed, the latest NetBeans IDE configured for Java EE development, and a local application server such as GlassFish or Payara ready. Once those pieces are confirmed, the rest of the workflow is mostly a matter of choosing the right archetype and letting the IDE handle the wiring. Working from a Brisbane cafe or your local setup, the steps below will walk you through the process from start to finish.

Preparing your NetBeans IDE environment

Open NetBeans and verify that the Java EE base IDE is active, not just the standard Java SE bundle. You can check this by looking at the New Project dialog — if the Java EE category is missing, install the additional plugins through Tools → Plugins. Australian developers working for local tech employers such as Atlassian often keep multiple distributions on hand for client work.

Make sure your JDK is at least version 11, since most modern Java EE archetypes target Jakarta EE 8 or later. You will also want to confirm that Maven is bundled with the IDE or that you have a standalone installation added to your PATH. A quick test in a terminal with mvn -version should report the expected Java home and Maven version. Once these checks pass, restart the IDE so any plugin changes are picked up.

Why Maven archetypes suit Java EE projects

Archetypes act as project templates that codify a known-good directory layout, dependency set, and plugin configuration. For Java EE work, this means you get a working pom.xml without manually tracking which API jars your session beans, message-driven beans, and servlets actually need. The archetype author has already verified the compatibility matrix, which removes a class of common setup bugs.

The trade-off is that archetypes can become outdated when the underlying specifications evolve. Before settling on one, check the archetype's release date and the Jakarta EE version it targets. An archetype aimed at older Java EE versions can still work, but the generated code may use deprecated annotations or rely on removed APIs. For long-term projects, prefer archetypes maintained within the last twelve to eighteen months.

Generating the archetype in the IDE

In NetBeans, choose File → New Project, then select Maven as the category and Project from Archetype as the project type. Click Next, and the IDE will display a searchable list of available archetypes drawn from Maven Central and any custom repositories you have configured. Filter by typing "javaee" or "jakartaee" to surface the official templates.

For most enterprise applications, the cargo-archetype-javaee7-minimal or a comparable stereotype-jakartaee-minimal is a sensible starting point. Select it, fill in the Group Id, Artifact Id, Version, and Package fields, and click Finish. NetBeans will resolve the archetype, generate the directory tree, and open the project in the Projects window. If you fancy a snack while the IDE resolves dependencies, a Tim Tam and a flat white are the classic Melbourne developer pairing.

Reviewing and adjusting the pom.xml

Open the generated pom.xml and look at the dependencies block. You should see entries for the Java EE APIs, the implementation libraries provided by your application server, and any test frameworks the archetype includes. If you plan to deploy to GlassFish, the provided scope on the implementation dependencies is correct; for Payara, the same principle applies.

Add or adjust plugins as needed. The maven-compiler-plugin should target your JDK version, and the maven-war-plugin should produce a deployable archive with the correct web.xml context root. Developers working from Perth or Adelaide often keep a parent pom in their company repository that enforces these plugin versions across teams. That parent pom removes a source of inconsistency and makes builds reproducible across environments.

Crafting session beans for business logic

Session beans encapsulate the work your application does on behalf of a client. In a fresh archetype, you typically find a sample class annotated with @Stateless that you can model your own beans on. Create new classes in the EJB package, mark them with @Stateless for transactions that do not maintain conversational state, or @Stateful when you need to track client-specific data across method calls.

Wire your beans through local interfaces when the consumers live in the same application, or through remote interfaces when other JVMs need to invoke them. The archetype will already have the EJB module configuration in place, so you only need to focus on the business methods. Avoid putting presentation logic in the beans themselves — that belongs in the web layer.

Building message-driven beans for async workloads

When you need to consume messages from a queue or topic without blocking the requesting session, message-driven-bean classes are the standard tool. The annotation is @MessageDriven, and you pair it with an activationConfig block that names the destination and the destination type. Most archetypes include a sample MDB that listens on a JMS queue, which makes it easier to understand the wiring.

For local development, an embedded broker or the application server's default JMS provider is usually enough. If your team uses an external broker in a production environment, update the connection factory settings in the deployment descriptors and make sure the destination JNDI names match. In Australian enterprises, brokers such as ActiveMQ Artemis are common, while a handful of Sydney-based fintechs standardise on IBM MQ for high-throughput transactional workloads.

Compiling and running the application

With the project complete, right-click the project node and choose Run. NetBeans will invoke Maven goals to compile, package, and deploy the application to the registered server. The output window shows the goal-by-goal progress, including any warnings about deprecated APIs or missing dependencies.

If the deployment succeeds, open a browser and navigate to the URL printed in the output, typically something like http://localhost:8080/your-app/. Developers who commute between Darwin and other hubs often test against remote staging servers before promoting code, which keeps the local machine free for fresh experiments. On the topic of staying active between long coding sessions, staying sharp on the court draws an interesting parallel from a former professional tennis player.