In 2018, Java is still the most popular programming language in the world. It comes with a vast ecosystem and more than 9 million Java developers worldwide. Although Java is not the most straightforward language, you don’t have to write Java programs from scratch. There are many excellent Java frameworks to write web and mobile applications, microservices, and REST APIs that run on the Java Virtual Machine.
Raygun lets you detect and diagnose errors and performance issues in your codebase with ease
Java frameworks allow you to focus on the business logic of your apps instead of writing basic functionality such as making database connections or handling exceptions. Also, if you have some experience with Java, you can get started quickly. The frameworks all use the same syntax and work with similar terms, paradigms, and concepts.
Our top 17 Java frameworks are based on usage through 2018 and listed alphabetically.
Blade: Simple application framework with a minimal footprint
Blade is a lightweight and high-performance Java framework that allows you to build fast web applications in a straightforward way. The creators want users to understand the whole framework in a single day. Therefore, Blade focuses on simplicity and elegance.
The Blade framework follows the MVC (Model-View-Controller) software design pattern. It has an easy-to-understand design, as it doesn’t depend on any third-party libraries or introduces too many layers. Blade is based on Java 8, and the Netty web server and template engine are built into the framework, too. It has a minimal footprint; the source code is less than 500kb in total.
With Blade, you have access to a RESTful-style routing interface and can deploy your app as a basic Maven project. Blade has built-in security features too, for instance, it comes with CSRF (Cross-Site Request Forgery) and XSS (Cross-site scripting) defense. It’s a versatile framework, as it comes with support for plugin extensions and webjar resources. The documentation on the main site is in Chinese. However, it does have English-language documentation in the GitHub repo.
Dropwizard: Production-ready RESTful web services
Dropwizard is a high-performance but straightforward Java framework for rapid development of RESTful web services. It’s especially suitable for creating Java microservices.
The Dropwizard framework pulls together several well-established Java libraries to provide you with a fast and distraction-free development platform. It comes with an embedded Jetty server, Google Guava, Logback, Hibernate Validator, Joda Time, and many other popular Java libraries. Besides, Dropwizard also contains Jersey with which you can build RESTful web services and Jackson for processing JSON. You can think of Dropwizard as a separate ecosystem that contains all the dependencies mentioned above bundled into a single package.
If you choose Dropwizard, you don’t have to spend much time on secondary functionalities like having to write your code for configuration, metrics, or logging. Instead, you can focus on the primary business logic of your app and achieve maximum productivity. That’s why Dropwizard is often referred to as an operations-friendly Java framework. Getting started is not very hard if you have written Java before; the Dropwizard docs even have a simple Hello World example that can help you with the first steps.
Grails: Groovy-based web application framework
Grails is a web application framework that uses the Groovy programming language. Groovy is an object-oriented language for the Java platform that intends to enhance developer productivity. Its syntax is compatible with Java, and it’s compiled to JVM (Java Virtual Machine) bytecode.
Although you need to write your code in Groovy, Grails works well with other Java-related technologies such as the Java Development Kit, Java EE containers, Hibernate, or Spring. Under the hood, Grails is built on top of Spring Boot so that it can make use of its productivity-friendly features such as Spring’s dependency injection. Probably the best thing about Grails is that you can achieve the same results with much less code—thanks to the power of the Groovy language.
Grails follows a handful of modern software development principles such as convention over configuration, opinionated APIs to enforce best practices, and sensible defaults. It’s also very developer-friendly, as it comes with a detailed and easy-to-read documentation, step-by-step guides, and an extensive plugin library. You can also build your own plugins and make use of Grails’ IDE support for Eclipse, Sublime, Textmate, IntelliJ IDEA, and other platforms.
GWT is pronounced as “gwit,” and it’s a stable and well-maintained Java framework. Nothing proves that better than its presence in several Google products such as AdWords, AdSense, Blogger, and Google Wallet. Google Web Toolkit has a spectacular website with all the tools and resources you may need, such as tutorials, developer guides, a starter application, and an Eclipse plugin.
Hibernate: Object-relational mapping framework for a better database communication
Hibernate is a stable object-relational mapping framework that makes better communication possible between the Java programming language and relational database management systems (RDBMSs).
When you work with object-oriented languages like Java, you’ll encounter a problem called Object-Relational Impedance Mismatch (sometimes also called Paradigm Mismatch). OO languages and RDBMSs handle data differently, which can lead to mis-match problems. While OO languages structure data as a hierarchy of objects, relational databases represent data in a tabular format. For instance, one of these mismatch problems is when the object model has more classes than the number of available tables in the relational database.
Hibernate provides you with a framework that overcomes the mismatch problems of Java. It intends to achieve persistence, meaning that the data created/used by the application should outlive the process that generated it. While Hibernate was built for relational databases, its newer versions provide support for NoSQL datastores as well. It also has excellent developer tools such as a mapping editor, a Hibernate console, and an awesome database reverse engineering tool.
JavaServer Faces (JSF): Component-based UI framework
JavaServer Faces (JSF) is developed by Oracle as a specification for building user interfaces for Java-based web applications. It’s an official standard of the Java Community Process (JCP) initiative as well.
The first version of JavaServer Faces was released back in 2004, so it’s a pretty stable framework. It follows the MVC software design pattern and has a component-based architecture. With JavaServer Faces, you can build user interfaces of reusable components, manage the state of your components, connect them to data sources, and bind user-generated events to event handlers on the server side.
The default templating system of JSF is Facelets that was created explicitly for the project. With Facelets, you can use XML instead of Java for view handling. However, you can also create views with other technologies such as XUL (XML User Interface Language) and plain Java. Web applications created with JavaServer Faces are portable across different Java EE application servers as well.
JHipster: Web apps and microservices with Spring Boot and Angular/React
JHipster is a newer Java framework (released in 2013) that brings the Spring Boot and the two most popular front-end frameworks (Angular and React) together, in one handy application generator. With JHipster, you can quickly generate modern Java-based web applications and microservices.
The Spring Boot allows you to create production-grade Spring-based applications (see more about the Spring Framework below in the article) that work with minimal configuration. JHipster combines it with Angular, React, and Bootstrap on the client side to provide you with a full-stack architecture. If you want to see how a JHipster app looks like in real-life, check out the sample apps for Angular and React, both created by the JHipster team.
JHipster lets you choose between two architectural styles. First, you can opt for a monolithic architecture in which the frontend and backend are combined into a single application. Second, you can go for the microservice architecture that splits the frontend and backend. JHipster also integrates with several tools, and offers a ton of options for client and server-side coding, bundling, plus different DevOps tasks. After all, it’s no coincidence leading brands like Adobe, Siemens, Bosch, HBO, and Google use JHipster.
MyBatis: Persistence framework for easier SQL management
MyBatis is a so-called persistence framework for Java applications, that makes it easier and faster to work with relational (SQL) databases. The framework acts as a middleware between the application and the database and fixes the issues stemming from their different architecture.
You can think of MyBatis as a layer of abstraction between the Java code of your application and the underlying SQL database. By default, you need to use the JDBC (Java Database Connectivity) API to access data sources like relational databases or spreadsheets from your Java code. MyBatis simplifies this process and lets you interact with relational databases with much less code. For instance, you can execute SQL statements with just a single line of code.
In fact, MyBatis is similar to the Hibernate framework, as both aim to improve the communication between the application layer and the database. However, MyBatis doesn’t map Java objects to database tables like Hibernate does, but links Java methods to SQL statements. As a result, SQL is not hidden from you when you are working with the MyBatis framework, and you still have control over the execution of SQL.
Play: Reactive web & mobile framework for highly scalable Java applications
The Play framework makes it possible to build lightweight and web-friendly Java and Scala applications for desktop and mobile interfaces. Play is an incredibly popular framework, used by companies like LinkedIn, Samsung, Walmart, The Guardian, Verizon, and many others.
Play is often compared to powerful web frameworks of other programming languages, such as Ruby on Rails for Ruby, or Django for Python. In fact, Play is a unique Java framework in the sense that it doesn’t rely on the Java EE standards. Instead, it intends to eliminate all the inconveniences of traditional Java web development such as slow development cycles and too much configuration. It more resembles the web frameworks of scripting languages (PHP, Python, Ruby, etc.) as much as possible.
Under the hood, Play is built on top of the Akka toolkit that simplifies the creation of concurrent and distributed applications on the Java Virtual Machine. As a result, Play uses a fully asynchronous model that leads to better scalability, especially because it also follows the statelessness principle.
The Play framework puts developer productivity first by offering features like hot code reloading, convention over configuration, and error messages in the browser. Besides, it’s a Reactive System that follows a modern system architecture (responsive, resilient, elastic, and message-driven) to achieve more flexible and failure-tolerant results.
PrimeFaces: UI framework for Java EE and JavaServer Faces
PrimeFaces is a popular web framework for creating lightweight user interfaces for Java EE and JavaServer Faces (see above) applications. It’s used by many Fortune 500 companies, government entities, and educational institutions.
The PrimeFaces library is truly lightweight. It’s packaged as a single JAR file, requires zero configuration, and doesn’t have any dependencies. It allows you to create a user interface for your Java application by offering you a rich set of components (100+), a built-in skinning framework, and pre-designed themes and layouts. As PrimeFaces is built on top of JavaServer Faces, it inherits its features such as rapid application development. You can also add the framework to any Java projects.
On the PrimeFaces website, you can find an excellent showcase of all PrimeFaces components, templates, and themes. The components come with relevant code snippets you can quickly copy/paste into your app—or tweak them when it’s necessary. For instance, here is a horizontal mega menu that lets you display submenus of root items together.
PrimeFaces also has an awesome theme designer which is a Sass-based theme engine with more than 500 variables, a sample theme, and font icons. And, if you don’t want to build a theme yourself, you can also download a community theme or purchase a premium one from the PrimeFaces Theme Gallery.
Spark Framework: Micro framework for web apps and REST APIs
Spark Framework is a micro framework and domain-specific language for the Java and Kotlin programming languages. Kotlin also runs on JVM, and it’s 100% interoperable with Java. With Spark, you can painlessly develop web applications, microservices, and REST APIs.
Micro frameworks first appeared in scripting languages like Ruby and PHP and quickly gained traction due to their focus on development speed and simplicity. Spark was inspired by the Sinatra web application framework for Ruby and first released in 2011. It’s not an MVC framework but lets you structure your app as you want. As with most micro frameworks, it has a small code base, needs minimal configuration, and doesn’t require you to write too much boilerplate code.
In fact, you can get the Spark framework up and running in just a few minutes. By default, it runs on the Jetty web server that is embedded into the framework. However, you can use it with other Java web servers as well. According to Spark’s own survey, more than 50% of their users used the framework to create REST APIs, which can be seen as its most popular use case. Spark also powers high-traffic web applications serving more than 10,000 users a day.
Spring Framework: Enterprise-level Java application framework
The Spring Framework is probably the most well-known Java framework out there, with a huge ecosystem and an active community around it. It allows you to build enterprise-level Java applications, web services, and microservices.
The Spring Framework started as a dependency injection tool, but over the years it has developed into a full-scale application framework. It provides you with an all-inclusive programming and configuration model that comes with support for generic tasks such as establishing a database connection or handling exceptions. Besides Java, you can also use the framework together with Kotlin and Groovy, both of which run on the Java Virtual Machine.
The Spring Framework utilizes the inversion of control (IoC) software design principle according to which the framework controls the custom-written code (as opposed to traditional programming where the custom code calls into other libraries that handle generic tasks). As a result, you can create loosely coupled modules for your Spring applications.
While the Spring Framework is excellent for building enterprise-level Java applications, it does have a steep learning curve. This is because it’s a broad framework that intends to provide a solution for every task that may come up with an enterprise-level application and also supports many different platforms. Therefore, the configuration, setup, build, and deployment processes all require multiple steps you might not want to deal with, especially if you are working on a smaller project. The Spring Boot (different from the Spring Framework) is a solution for this problem, as it allows you to set up your Spring application faster, with much less configuration.
Struts: MVC framework for enterprise-level Java applications
Struts is quite an old framework, but many people still use it, therefore it’s worth a mention in this article.
Struts is a full-featured Java web application framework maintained and developed by the Apache Software Foundation. It’s a solid platform with a vast community, often compared to the Spring Framework. Struts allow you to create enterprise-level Java applications that are easy to maintain over time.
It follows the MVC software design pattern and has a plugin-based architecture. Plugins make it possible to extend the framework to fit with different project needs. Struts plugins are basic JAR packages. Therefore, they are portable and you can also add them to the classpath of your app. Some plugins are bundled with the framework (JSON plugin, REST plugin, Config Browser Plugin, etc.), while you can add others from third-party sources.
You can integrate Struts with other Java frameworks to perform tasks that are not built into the platform. For instance, you can use the Spring plugin for dependency injection or the Hibernate plugin for object-relational mapping. Struts also let you use different client-side technologies to build the front-end of your app, such as JavaServer Pages or HTML with Angular.
However, if you want to create server-side components that can render on the front-end, Struts may not be the best choice for that. Instead, you should look into a framework that has a different architecture such as Tapestry or Wicket (see both below). Also note that Struts got some bad press recently due to some critical security vulnerabilities you still need to be aware of.
Tapestry: Component-oriented framework for highly scalable apps
Tapestry is a component-based Java framework with which you can create scalable web applications. Its focus on reusable components makes it architecturally similar to JavaServer Faces and the Wicket framework. Just like Struts, Tapestry is also a project of the Apache Software Foundation.
You can write Tapestry pages and components as plain old Java objects (POJOs). Therefore, you can access the whole Java ecosystem from the framework. Besides Java, Tapestry also supports Groovy and Scala and integrates with other Java frameworks such as Hibernate and Spring. Tapestry has been built with performance in mind; therefore it provides you with features like live class reloading, exception reporting, Ajax support, and built-in components and templates.
Vaadin: Web application framework with a focus on UX, accessibility, and mobile
Vaadin provides you with a platform for streamlined Java development. It allows you to build web applications of customizable components that focus on performance, UX, and accessibility.
The most interesting thing to know about Vaadin is that its latest release (just a few days ago, in June 2018) has been so significant that even major media outlets reported it. Vaadin 10 approaches web app development in an entirely new way: it gives developers direct access to the DOM from the Java Virtual Machine. With the new release, the Vaadin team split the previously monolithic framework into two parts. It has a lightweight Java framework called Vaadin Flow that handles routing and server-client communication and a set of UI components that run in the user’s browser.
The components are mobile-first and follow the latest web and accessibility standards; they were built on the Web Components standards. You can use Vaadin components together with any front-end framework such as React, Angular, or Vue. The creators also recommend them as building blocks for Progressive Web Apps. You can build your own theme based on Vaadin components or use Vaadin’s two pre-made themes: Lumo (default) and Material.
Vaadin Flow provides you with a high-level Java API to manage all the technical aspects of your app, from automatic server-client communication via WebSockets to data binding. As Flow runs on the JVM, you have access to the whole Java ecosystem, for instance, you can run your app with the Spring Boot. Flow also lets you write your app in Kotlin or Scala.
Vert.x: Polyglot event-driven application framework for the Java Virtual Machine
Vert.x is developed and maintained by the Eclipse Foundation whose most famous project is the Eclipse IDE for Java development. And, who would know more about Java than the creator of Eclipse? The ‘x’ in Vert.x refers to its polyglottic nature, meaning that you can write valid code in several different languages. It provides idiomatic APIs for every supported programming language.
As Vert.x is an event-driven and non-blocking framework, it can handle a lot of concurrencies using only a minimal number of threads. Vert.x is also quite lightweight, with the core framework weighing only about 650 kb. It has a modular architecture that allows you to use only the modules you need so that your app can stay as slick as possible. Vert.x is an ideal choice if you want to build lightweight, highly scalable microservices.
Wicket: Component-based web application framework for purists
Wicket is a component-based web application framework similar to JavaServer Faces and Tapestry. It allows you to write elegant, user-friendly apps using pure Java and HTML code. The framework is maintained by the Apache Software Foundation, just like Struts and Tapestry.
When it comes to Java frameworks, keep an open mind and research which one is best for you. There are so many frameworks that will suit your project, so use this guide to assess your needs.
Raygun crash reporting and error monitoring is easily available with raygun4java. Raygun4java is a library that you can easily add to your Java application, which will then allow you to transmit all exceptions to your Raygun dashboard. Installation is painless, and configuring your site to transmit errors takes only 5 minutes. Sign up for a free 14-day trial.