Most Popular Java Web Frameworks
Tags: java, webdev
Published: 2019-01-03 17:51:41

---
title: Most Popular Java Web Frameworks
published: true
tags: #java #webdev
description: Our list of top Java frameworks is based on usage from hotframeworks.com and several other sources including blog posts and GitHub download numbers.
canonical_url: https://rollbar.com/blog/most-popular-java-web-frameworks/
---

As Java has evolved over the years, multiple attempts have been made to simplify development for various use cases. From official standards like Java Enterprise Edition, to community-driven frameworks, Java is continuing to prove itself to be adaptable and viable.

Our top list is based on usage from **[Hotframework.com's Java ranking](https://hotframeworks.com/languages/java)** and several other sources including blog posts and GitHub download numbers.

The top three are:

* [Spring](#Spring)
* [JSF](#JSF)
* [GWT](#GWT)

Other notable Java Web Frameworks:

* [Play!](https://www.playframework.com/)
* [Struts](https://struts.apache.org/)
* [Vaadin](https://vaadin.com/)
* [Grails](https://grails.org/)

Java Frameworks that are popular but not for the Web (We don’t want to forget them):

* [Hibernate](http://hibernate.org/) (Data-focused)
* [Maven](https://maven.apache.org/) (Build-focused)
* [Apache Ant](http://ant.apache.org/) with [Ivy](https://ant.apache.org/ivy/) (Build-focused)

<a name="Spring"></a>
## Spring

Project Site: [https://spring.io/](https://spring.io/)

Primary Sponsor: [Pivotal Software](https://pivotal.io/)

Spring is more than just a web framework. It is a complete programming model that is built on and with Java, starting with Spring Boot, which is a way to get a spring application up and running with minimal configuration and no application server required. At the other end of the spectrum is Spring Cloud, which is a combination of components that allows developers to build resilient and reliable cloud-native applications that leverage the latest distributed patterns like a microservices architecture — two examples include application [security](https://projects.spring.io/spring-security/) and [batch](https://projects.spring.io/spring-batch/) processing.

There are many use cases for Spring, and with the introduction of Spring Boot, it is a great solution for companies that are moving towards containers as it greatly simplifies the components required to support the running application.

Getting started with Spring is as simple as going to [Spring Initializr](https://start.spring.io/) and selecting the build framework you desire and any and all the Spring projects you want included in the initial application. It will create the Maven or Gradle configuration and all the basic spring configuration required to start.

Creating a simple web application starting with Initializr (Figure 1):

![Spring Initializr](https://thepracticaldev.s3.amazonaws.com/i/ejn2edbcelm2z1191hqb.png)

… which will create a Zip file with the following files in it:

```
./mvnw.cmd
./pom.xml
./.gitignore
./.mvn/wrapper/maven-wrapper.properties
./.mvn/wrapper/maven-wrapper.jar
./mvnw
./src/test/java/com/example/demo/DemoApplicationTests.java
./src/main/resources/application.properties
./src/main/java/com/example/demo/DemoApplication.java
```

You need a Controller — `src/main/java/com/example/demo/DemoController.java`:

```java
package com.example.demo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class DemoController {

    @RequestMapping("/hello")
    public String hello() {
        return "hello";
    }

}
```

And a template file — `src/main/resources/templates/hello.html`

```html
<!DOCTYPE HTML>
<html>
<head>
    <title>Hello World</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
    <p>Hello World</p>
</body>
</html>
```

<a name="JSF"></a>
## JSF (Java Server Faces)

Project Site: **[http://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html](http://www.oracle.com/technetwork/java/javaee/javaserverfaces-139869.html)**

Primary Sponsor: **[Oracle](https://www.oracle.com/index.html) ([soon to be a separate foundation](https://blogs.oracle.com/theaquarium/opening-up-java-ee))**

JSF is a specification for displaying web user interfaces that is defined as part of the Java Platform, Enterprise Edition (JEE). JSF 1 was released in 2004, incorporated into JEE 5 and uses Java Server Pages (.jsp) as its templates. JSF 2 was released in 2009 as part of JEE 6, and leverages Facelets for templating and supports AJAX calls with a browser to allow modern web application lifecycles. JSF is component-based, allowing it to be expanded with additional components. **[IceFaces](https://www.icesoft.com/icefaces/)** and **[MyFaces](https://myfaces.apache.org/)** are examples of popular add-on components.

As JSF is part of the Java standard, it is popular with development teams that want to stick to published standards for increased portability across platforms. JSF also allows existing backend Java code to be extended with a web interface without having to refactor the base application by introducing a new framework.

A simple JSF application requires a Managed Bean, Facelet, and mapping the servlet.

helloworld.java

```java
package helloworld;

import javax.faces.bean.ManagedBean;

@ManagedBean
public class HelloWorld {

    final String world = "Hello World!";

    public String getworld() {
        return world;
    }
}
```

helloworld.xhtml

```html
<html lang="en"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelets Hello World</title>
    </h:head>
    <h:body>
        #{hello.world}
    </h:body>
</html>
```

web.xml

```xml
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
```

<a name="GWT"></a>
## GWT (Google Web Toolkit)

Project Site: **[http://www.gwtproject.org/](http://www.gwtproject.org/)**

Primary Sponsor: Google

GWT is much like JSF in that it is strictly focused on building web interfaces. It is more popular than native JSF as it makes it easy to maintain complex JavaScript user interfaces with Java code. GWT has lost some of its popularity over the last couple of years as more development teams are pushing Java to the backend and having it expose REST APIs which are consumed by both native mobile apps and user interfaces built in Node.js, using frameworks like **[Angular](https://angular.io/)**.

A tutorial on how to build a simple GWT application can be found on its project site: **[Getting Started building a GWT app](http://www.gwtproject.org/doc/latest/tutorial/gettingstarted.html)**.

## Conclusion

In summary, there are many viable Java Web Frameworks that can be used to address your needs. None of the top three are bad choices — It comes down to personal preference. Just be aware that once you commit to a framework and start to leverage its features, switching to another framework is not an insignificant amount of work.

_Originally published on [rollbar.com](https://rollbar.com/blog/most-popular-java-web-frameworks/)_