It’s as true for Java developers as it is for woodworkers: You can’t do the job right without the right tools. Fortunately, there’s no shortage of frameworks, build tools, profilers, and integrated development environments (IDEs) available to Java developers. And while no one tool is perfect for everyone, we looked at 11 top choices—listed in alphabetical order—to help you consider which ones might be best for you and your projects.
Gradle is a relatively new build-management tool, but it’s already attracted a huge following; in fact, it’s the default build system for Google’s Android operating system. Unlike older tools such as Apache’s Maven and Ant that use XML build files, Gradle uses two domain-specific languages (DSLs): Kotlin and Apache Groovy. The majority of Gradle’s documentation is written using the Groovy DSL, but the Kotlin DSL has better integrations with IDEs.
Gradle strikes a good balance between extensibility and structure. Its conventions are useful, but you can easily override them if you need to. Gradle files are generally broken up into tasks, which allows for incremental development and means less time getting stuck in dependency hell. Gradle makes smart decisions about when to avoid unnecessary work; for example, it will reuse build outputs from previous builds and keep a daemon running to keep information in memory.
If you’re looking for flexibility, ease of use, and speedy builds, Gradle is your build tool.
Apache Groovy is really a programming language, not a straightforward tool or library, but its ubiquity and value for testing merits its inclusion on this list. As its name suggests, Groovy is the chiller, more relaxed cousin of Java. Its syntax is Java syntax, but with fewer rules, which makes it easier to read. Groovy helps you avoid much of the work Java would make you do; for example, it auto-imports commonly used classes, adds optionally typed variable declarations, and boasts strong scripting capabilities. Groovy can be compiled to Java bytecode just like a normal Java program, or you can execute it using shell scripts.
Smart design decisions that make Groovy useful for testing make this an exceptional tool. For example, access modifiers are optional. As a result, Groovy tests can read and check the internal state of the code being tested. Groovy also has a type of assert statement called the power assert, which evaluates every aspect of an assert statement to clearly show what failed, instead of simply comparing expected versus actual results.
While Groovy isn’t a candidate to replace Java, it should be an important component of your development toolbox, especially if you’re into writing strong tests.
IntelliJ versus Eclipse: few software debates inspire as much anguish and strife as this one. Both IDEs are powerful, highly extensible, easily navigable, and make writing Java code a more pleasant experience. But when it comes to user experience, IntelliJ can’t be beat. It’s fast, polished, and cohesive. While the repeated indexing can be frustrating, it serves a valuable purpose, allowing IntelliJ to maintain a comprehensive view of your entire project at all times. This means up-to-date error highlighting, seamless code completion, and speedy navigation across your entire project.
IntelliJ comes with plenty of shortcuts and tips, and there’s a plugin available for almost every situation. For example, do you need to write a bash script in your project? There’s a plugin for that. Need to write some regexes to test against console output? There’s a plugin for that, too. IntelliJ makes refactoring a breeze by previewing your potential changes and showing you any conflicts. While every IDE has its pros and cons, IntelliJ makes for a smooth development experience.
With great code comes even greater tests, and JaCoCo helps ensure your Java code is well tested. This free code-coverage tool generates reports that detail how much of your code is covered by unit tests. For example, when you run a JUnit test, JaCoCo instruments the class files used in the tests and then creates a .exec file. Another task uses that file to generate an HTML, XML, or text file that contains your coverage report.
The JaCoCo report is color coded: green indicates all code paths have been covered; yellow indicates that the paths are partially covered; and red indicates that the paths are completely uncovered. The report also gives you a percentage overview of how much of your instructions and branches were covered, and it also gives you a score for cyclomatic complexity. Once you have that coverage report, adjust your tests to ensure your code is adequately covered.
With JaCoCo, any developer can create a complete, in-depth test suite to suit for even the most complicated application. It’s compatible with both Gradle and Maven, and has plugins for Eclipse and IntelliJ.
JMeter is an open source load-and-performance testing tool that includes multiple categories of tests, including load, functional, performance, and regression tests. It’s the gold standard for load testing because it gives you the greatest insight into your application’s weak spots when it’s under stressful conditions. While JMeter does have higher overhead than other load-testing tools, it also collects the most data and does the most processing. It produces a comprehensive, accurate look at how your application performs under load.
JMeter is highly configurable and platform-agnostic, and you can implement additional features with plugins. It’s fairly easy to edit, as it stores its test plans in XML files.
It almost unnecessary to write about how good JUnit is. JUnit is the dominant unit testing framework for Java development—and for good reason. Mockito is great for behavior-driven development, but JUnit is the king of test-driven development. A good part of its dominance is due to the fact that you can test one block of code at a time, which means actually being able to test and then code, instead of completing a feature and then scrambling to write tests. Its annotations reduce boilerplate code while cleaning up your test suite.
JUnit is continuing to get better with every major release. For example, JUnit 5 introduced lambda support, an annotation for nesting groups of tests into one test class, and a way for other test frameworks to create engines that can be run in every tool that supports JUnit 5. This means that new testing frameworks get the same platform support as JUnit 5, which makes adoption of these frameworks much faster and less painful.
So while it feels silly to include something as well known as JUnit on this list, it would be a far graver sin to leave it off. JUnit is a cornerstone of Java development, and it deserves its place on every list of top Java tools.
If you’re a Java developer who believes in behavior-driven development, you’re probably already familiar with Mockito. This open source mocking framework creates mocks and spies in a simple, readable way. Mockito helps you create clean tests and, by extension, loosely coupled code. You can also use it to mock out classes and interfaces. Using spies instead of mocks means you can end up with fewer lines of code and more realistic tests to predict your application’s actual behavior.
Mockito (as well as other mocking frameworks) can be difficult to maintain, but its clean tests and mocking capabilities make the extra maintenance worth it.
A lightweight Java web framework, Spark is intended for rapid development with as little overhead as possible. It’s geared toward writing microservices, which is evident in its design philosophy. Inspired by the Ruby framework Sinatra, Spark was built around Java 8 lambda expressions. Its API is simple, flexible, and easy to use, making it a favorite for developers building RESTful APIs.
If you’re looking for a massive Java framework to do all of the heavy lifting for you, Spark is not the best choice. But if you want a sleek, expressive framework that will keep your Java code clean and nearly boilerplate-free, then Spark is the way to go.
SpotBugs is an open source project for static code analysis. Just as the name says, it’s designed to literally spots bugs before you do. Using more than 400 bug patterns, SpotBugs digs deep into your code to expose possible bugs, which allows for near-immediate bug detection and correction. It then categorizes its findings into one of four levels: “of concern,” “troubling,” “scary,” and “scariest.”
SpotBugs is the successor to FindBugs, last released in March 2015. The community has aligned behind SpotBugs, and it now has an active group of contributors and maintainers pushing the project forward. SpotBugs is available through Ant, Maven, Gradle, and Eclipse integrations.
SpotBugs can save you a lot of pain by identifying and classifying bugs before they impact your users.
The Spring framework is a popular dependency injection framework. In practice, however, it’s a jungle of features and helpers that could be daunting even for seasoned users. Spring Boot seeks to alleviate those complications to make developing Java-based Spring applications easier for all users—think of it as a machete for cutting through the Spring framework jungle. Technically, though, it’s not much more than a way to create opinionated instances of Spring applications.
To use Spring Boot, you first choose a starter, which is basically a pre-configured set of dependencies suited to the type of application you want to build. For example, if you’re working on a RESTful web service using Spring MVC and Tomcat, you would choose spring-boot-starter-web. You can use annotations like @EnableAutoConfiguration to finish setting up your application, and then you have a fully configured Spring application ready to run.
Spring Boot is the perfect tool for taming the Spring framework while leveraging its power.
Code that runs is good, but high-performing, efficient code is amazing. Java profilers like YourKit help you identify memory leaks, compare the consequences of different code paths, and diagnose other performance problems to help ensure the code you write is on the amazing end. You can use YourKit for on-demand, local, and remote profiling.
Like JProfiler, YourKit integrates seamlessly with major IDEs, making it a natural part of the development process. Unlike many other profilers, though, YourKit can profile specific sections of code at a time, helping you examine different code paths through its what-if feature.
YourKit also has powerful exception-profiling capabilities: it shows you the type of exception being thrown and the number of times it was thrown. Finally, you can profile various kinds of database calls, right down to the queries that were executed.
What sets YourKit apart from other profilers is just how intuitive and easy it is to use. Even inexperienced developers can open heap dumps, analyze them, and understand YourKit’s path-based leak detection philosophy. In fact, YourKit’s powerful profiling capabilities makes heap dumps easily digestible and fun to investigate.
Obviously, you won’t use these tools in isolation from each other, and it’s more than likely that your tool box will include several of these. There there are also plenty of other popular and proven Java development tools not covered on this list, such as Eclipse (IDE) and Maven (build tool). If you’re only using a tool occasionally, ease of use is important. Personal preference can be just as important as objective criteria—if it works for you, who’s to say it’s not the right way to go.