Enterprise Java

Truly Unleashing the Power of Maven and Java EE

Ambition and vision can be the undoing of great solutions, if they are too complex to use. While Maven and Java EE are technologies that are well established throughout the Java industry, it can be extremely tricky to get started with them and to architect projects using all the techniques and patterns that their authors intended you to use.

How often do applications, midway in the development process, not need to be set up afresh again because of a flaw that crept into their architecture right at the beginning? How much time is spent in drawing out and mapping the relationships between artifacts in an application, right at the beginning, only for all those plans and designs to gradually be forgotten and an unresolvable mess of spaghetti code to gradually arise instead?

Here is where the right tools are essential and, when looking at all the available tools that relate to Maven and Java EE, it can be seen that NetBeans IDE, in particular, has been created to be both “Maven centric” and “Java EE centric”. What that means is that NetBeans IDE does not simply “support Maven” and “support Java EE”. No, NetBeans IDE has been developed over many years around the ideas and architectures that the authors of Maven and Java EE have always had in mind for you to use.

Maven

The key to unlocking Maven is to realize that NetBeans IDE natively (i.e., “out of the box”) understands the POM file that defines the project structure common to all Maven projects. What makes Maven unique is that it standardizes project structures, enabling NetBeans IDE to natively provide standardized tools to support those project structures.

Imagine a tool were to natively understand a Maven POM file. What assumptions should you be able to make of such a tool?

You should be able to assume one or more of the following:

  1. No import process should be needed to convert a Maven project to some kind of internal structure inherent to the tool in question.
  2. An “Open Project” command applicable to any other kind of application should work in exactly the same way for Maven, i.e., you’d assume you’d be able to browse to a folder containing the POM and then the tool should simply be able to open the Maven project and visualize it in some way in the tool. The visualization of the Maven project should be helpful and logical and, for example, enable you to see all the entry points easily.
  3. The tool should be able to integrate its project-level commands with the goals defined in the POM, so that when you invoke a “Build Project” command, that you’d be able to map that command to Maven goals specific to the project, such as “mvn install”, for example.
  4. Maven commands run in the tool should run and behave in the same way as on the command line, while producing the same kind of output as provided by a continuous build server, such as Jenkins.
  5. The Maven dependencies should be visualized in some way, such that their interrelated connections can be viewed in some kind of reconfigurable and customizable set of diagrams.

Each of the assumptions above are realized in NetBeans IDE.

No importation process of any kind is needed to get a Maven project into NetBeans IDE. No plugin needs to be installed. Nothing needs to be configured. Simply go to File | Open Project (Ctrl-Shift-O) and browse to any folder containing a POM, such as the open source multi-module JAnnocessor framework. As you can see here, the IDE recognizes the project, while you’ve had to do nothing at all to “convince” the IDE that the project should somehow be openable, i.e., the IDE recognizes the project automatically, since the folder you’ve browsed to has a POM file. Click “Open Project” below and the IDE opens and visualizes the project in the Projects window.

unlock-11

Similarly, you can use the IDE’s Git tools, which are also baked into the IDE, no plugins or configuration needed:

unlock-7

For example, simply point to Arquillian lead Aslak Knutsen’s new Simple Arquillian HelloWorld Example project, as shown below…

unlock-8

…and, at the end of the Git process, you’ll automatically have the Maven project open in the IDE, without having needed to do anything at all, since the IDE understands the POM file and organizes the Maven project coherently in the IDE based on the parsing of the POM file:

unlock-9

If the Maven project incorporates Java EE RESTful Web Services, the IDE visualizes the services as entry points into the application, as shown below:

unlock-10

As with other IDEs and tools, the IDE lets you run project-level commands, such as “Build” and “Run”, as shown below…

unlock-6

…however, what happens when those commands are invoked is completely up to you, i.e., use the Project Properties dialog of the Maven project to map Maven goals to project commands, as shown below:

unlock-5

A final point is that the dependencies in the POM are visualized and their relationships rendered in a customizable diagram, as shown here:

unlock-4

Moreover, as shown above by the fact that there’s an “Effective” tab, you can see where each entry in a multi-module project’s POM file comes from, as can be seen here, too:

unlock-12

Now that we have explored the deep integration of Maven with the IDE, let’s turn to Java EE, which is, of course, often used in combination with Maven.

Java EE

The key to unlocking Java EE is to realize that the engineers who lead the Java EE specifications work for the same organization as the engineers who develop NetBeans IDE. Originally, the main driving force behind the Java EE platform was Sun Microsystems, while that has, of course, become Oracle, over the past few years. All along, NetBeans IDE is the development tool that has been positioned, by Sun Microsystems as well as Oracle, as the official IDE for the Java platform.

Imagine a tool were to be developed by engineers at the same organization as where the Java EE platform itself is driven and developed. What assumptions should you be able to make of such a tool?

You should be able to assume one or more of the following:

  1. When new specifications of the Java EE platform are released, a new version of the tool should be released, too. Generally, the current release of the tool should be synchronized with the current release of the Java EE platform.
  2. The official documentation and tutorials of the Java EE platform should, from beginning to end, use the tool as the entry point to understanding the Java EE platform.
  3. The tool should provide, out of the box, a lot more than a simple “hello world” example for getting started with the Java EE platform. More specifically, the tool should provide a very wide range of samples that help to understand far more than the simple basic components of the Java EE platform, in fact, the tool should provide, out of the box, complete scenarios that encapsulate best practices and enable newbies to the Java EE platform to be confident in building their applications based on the recommendations made available by the built-in examples.
  4. The key components of the Java EE platform should be easy to set up in the tool. The tool should be the central mechanism for getting to grips with the Java EE platform and should be structured in such a way that each new release of the Java EE platform should be easy to understand via templates, code generators, and keyboard shortcuts that the tool should make available specifically for the Java EE platform.
  5. Key members of the community around the Java EE platform should recognize and promote the tool as being the ideal way to come to grips with the Java EE platform.

The assumptions above are all, without exception, realized in NetBeans IDE. The IDE is always the first to provide tools and a variety of related features applicable to the latest release of the Java EE platform.

At the same time, out of the box, the IDE comes with a wide range of simple as well as complex examples relevant to understanding each of the key components that make up the Java EE platform. Go to File | New Project (Ctrl-Shift-N) and you should see the immense range of Java EE examples for yourself, available and working out of the box, with the aim to help you get up and running with the key components of the Java EE platform:

unlock-1

Getting started with the Java EE platform is helped considerably via comprehensive templates, which generate large segments of a Java EE application, such as all the JPA entity classes from a database, or all JAX-RS RESTful Web Services from JPA entity classes or a database, as shown here:

unlock-2

Related to the above, the official Java EE tutorial uses NetBeans IDE throughout from beginning to end as the tool most well suited for creating applications that comply with the specifications conforming to the Java EE platform:

unlock-3

Throughout the Java EE community, you’ll find leading enthusiasts talking about NetBeans IDE as the simplest tool for learning about Java EE. In particular, probably the most well known Java EE advocate, Adam Bien—who is affiliated to no one other than himself—continuously uses NetBeans IDE as the tool in which he does all his demos, as well as his own enterprise work, as can be seen on his YouTube channel, as well as in all the conferences in which he speaks.

Conclusion

The key argument made in this article is not that NetBeans IDE has a variety of features that integrate well with Maven and the Java EE platform.

Instead, and in sharp contrast to that perspective, the key argument made in this article is that NetBeans IDE is “Maven centric” and “Java EE centric”. From the above, the meaning of these terms should be clear—both Maven and Java EE are baked into the very essence of what NetBeans IDE is, as its heartbeat, and as its raison d’être.

Should you be interested in truly unleashing the power of Maven or Java EE, and especially both of these together, you should seriously evaluate NetBeans IDE as one of your key weapons of choice—especially since it is, of course, 100% free and open source.

Geertjan Wielenga

Geertjan is involved with a variety of open source projects, in particular, with NetBeans IDE, the official IDE for the Java platform.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button