8 Tools for Every Java Developer’s Toolkit

 

Java Developers Toolkit Blog Header

Java developers have an enormous selection of libraries, utilities, and programs at their disposal. Each one has its merits, but there are a few that stand out from the crowd due to their popularity, versatility, and usefulness.

These eight tools cover the full gamut of Java development, from code building to bug squashing. Learning these tools can help you improve the quality of your code and become a more efficient Java developer.

Eclipse

Despite the increasing popularity of IntelliJ IDEA, NetBeans, and other IDEs, surveys indicate that Eclipse is still the preferred development environment for almost half of Java developers. Eclipse is the Swiss army knife of IDEs, featuring a heavily customizable interface and countless plugins. It’s so ubiquitous that all of the other tools in this post provide Eclipse plugins.

Java Toolkit image 02

Eclipse separates its workflow into three areas: the Workbench, the workspace, and the perspective. The Workbench acts as the starting point to the IDE. Workspaces group projects, files, and configuration settings under a single directory. Perspectives define the tools, views, and settings available in the Workbench based on the context of the workspace. Although new developers might find it more difficult to use than Netbeans or IntelliJ IDEA, Eclipse’s flexibility makes it the preferred IDE for enterprise development.

Luna, the latest version of Eclipse, brings support for Java 8, split-screen editing, a new dark theme, and a fully functional command line terminal.

Gradle

Gradle is a project automation tool that builds on the features of Apache Maven and Apache Ant. While Gradle isn’t the most popular build tool available (that honor goes to Maven, which 64% of Java developers prefer), it’s quickly gaining popularity. It also serves as the default build tool for Android.

Java Toolkit image 01

Gradle prides itself on simplicity. Gradle uses the Groovy programming language as opposed to the XML syntax used by Maven and Ant. A basic Gradle build file for a Java project consists of a single line:

apply plugin: 'java'.

The following command generates a Gradle build file, creates a directory tree for project files, and bundles a portable Gradle wrapper with the project:

$ gradle init --type java-library

Gradle includes additional plugins for adding new languages, generating project files for IDEs, building native binaries, checking for updated dependencies, and more.

For more information, see the Gradle Getting Started guide for Java/JVM.

Javadoc

Javadoc is a documentation generator provided by Oracle. It parses specially formatted comments into HTML documents. This screenshot shows the Java SE 8 API specification as generated by Javadoc:

Java Toolkit image 04

Javadoc comments are formatted using an opening tag, a closing tag, and one or more descriptive tags. The opening tag is similar to the standard Java multi-line comment tag, except it uses two asterisks. Javadoc also parses plain HTML tags.

Javadoc automatically formats tags and keywords unless otherwise specified. Javadoc also makes extensive use of hyperlinks, allowing you to reference and link to separate areas of code. Many IDEs—including Eclipse—can automatically add Javadoc comment blocks to variables, classes, and methods. Plugins for Maven, Gradle, and Ant build Javadoc HTML along with your compiled code. For more information, see the Oracle article How to Write Doc Comments for the Javadoc Tool.

JUnit

JUnit is an open source framework for writing and running unit tests. A basic JUnit test consists of a testing class, a testing method, and the functionality to be tested. JUnit uses annotations to determine how tests are structured and ran. For example, if your program has a class called MathClass with methods for multiplication and division, you can create JUnit tests to check for unexpected values. When passing the numbers 2 and 5 to the multiplication method, you’d expect to receive 10 as a result. When passing 0 as the second parameter to the division method, you’d expect an ArithmeticException to be thrown due to a division by zero:

The @Test annotation specifies that the method is a test case. JUnit provides additional annotations such as @Before, which you can use to set up the environment before the test runs. JUnit also lets you set Rules that define how the test methods behave. For example, the TemporaryFolder rule causes files or folders created by a test to be deleted once the test finishes.

For more information, see Getting Started with JUnit. Vogella also provides a tutorial on unit testing with JUnit.

Cobertura

Cobertura, a jcoverage fork, analyzes Java code for test coverage. Cobertura generates HTML-based reports based on the amount of code that isn’t covered by testing.

Java Toolkit image 03

Cobertura provides tools for instrumenting, checking, and testing code. By monitoring instrumented code, Cobertura allows you to use your testing framework of choice or even run the program without a testing framework.

Cobertura reports code coverage in terms of lines, branches, and packages. Each category has a customizable threshold that triggers a warning if coverage falls below the threshold. Cobertura also integrates with Maven and Gradle for automatic detection.

Mkyong.com provides an example for integrating Cobertura with Maven.

FindBugs

FindBugs is a tool that pattern-matches compiled code against a database of bugs. When provided with the source code, FindBugs also highlights the lines of code affected by detected bugs.

Java Toolkit image 00

As of version 3.0.1, FindBugs maintains hundreds of bug descriptions. Bugs are categorized into four levels based on their severity: of concern, troubling, scary, and scariest. In addition to a GUI, FindBugs provides a command-line interface, an Ant task, and an Eclipse plugin.

VisualVM

Included in the JDK, VisualVM is a utility for monitoring and reviewing the performance of Java applications. VisualVM detects and attaches to active JVM instances to retrieve diagnostic information about a process.

Java Toolkit image 05

VisualVM makes it easy to diagnose performance issues in real time. It provides a full suite of profiling tools including JConsole, jstack, jmap, jinfo, and jstat. Additionally, you can take a snapshot of a JVM at any time for later review.

Groovy

Groovy is a programming language that both simplifies and extends Java by adding new keywords, auto-importing commonly used classes, and optionally typed variable declarations.

One of Groovy’s core strengths is its scripting capabilities. Classes can be compiled as Java bytecode or executed dynamically using the Groovy Shell. Groovy’s Java base makes it more accessible to Java developers when compared with Jython or JRuby.

For more information, see the Groovy Getting Started guide.

Other Options

The Java landscape is constantly changing with new tools, utilities, and libraries. If your preferred tool didn’t make the list, feel free to share it in the comments below.


Andre Newman is a software developer and writer on all things tech. With over eight years of experience in Java, .NET, C++, and Python, Andre has developed software for remote systems management, online retail, and real-time web applications. He currently manages 8-bit Buddhism, a blog that blends technology with spirituality.

 


5 comments

  • Tomas Milton

    2 months ago

    Great post, thanks! I have tried many IDEs for Java programmers (NetBeans, Eclipse, IntelliJ IDEA, Android Studio, BlueJ) but I have come to the conclusion that the best one is Eclipse. Also you can try IntelliJ IDEA. But still I think it is rather personal opinion, you should try some of tools and then chose the best for you.

  • Developer utils

    6 months ago

    Having worked for years with both Eclipse and InteliJ, I think that Eclipse is easier to get used to, but for the long run, InteliJ is better.
    Despite those sophisticated tools, often you do need a quick utility to get something done, and an online utility is the best option.
    Here’s a site I created with such utilities like epoch converter, XML-JSON converter, JSON and XML checkers, formatters, certificate decoder and more. Hope this helps

  • fyvacuumi.tumblr.com

    7 months ago

    Awesome post.

  • Jack Martin

    9 months ago

    Very nice and interesting post. I have even framed few points about Automated Testing of Java apps. Hope you would like it – http://bit.ly/1M47DeI

Share Your Thoughts

Top