Java is a robust language and when combined with a framework, Java can provide the best solutions for any domain be it e-commerce, banking, cloud computing, finance, big data, stock market, IT and more.
If you are just starting with Java, see Java live in action with this blog that will run you through all the important concepts you need to know to start working with the frameworks.
Frameworks give a structure to your applications. For example, if we have a proper framework for testing, we can automate a lot of things and get accurate and consistent results. Same way if there are frameworks for ORM, web applications, logging, data management etc… it will make a developer’s life simple and help them concentrate more on business logic rather than worrying about common pieces of code used across a domain or application.
The best Java frameworks
Although there are many frameworks built on Java, here are some very commonly used frameworks of different types – web applications, network applications, logging, testing, ORM etc… Note that each of these has their own benefits and can work best for different business use cases. We cannot say which is better because they are all good in different scenarios.
With its concept of Dependency Injection and aspect-oriented programming features, Spring took the development world by storm. It is an open-source framework used for Enterprise applications.
With Spring, developers can create loosely coupled modules where-in dependencies are handled by the framework rather than depending on the libraries in the code.
Spring framework is exhaustive and covers a lot of features including security and configuration, which are easy to learn. Further, since it is the most popular web framework, you can find a lot of documentation and an active community.
With everything configured, your code will be clean and easy to comprehend.
Main concepts –
- Dependency Injection (DI) (Inversion of Control) – In this principle, rather than the application taking control of the flow sequentially, it gives the control to an external controller who drives the flow. The external controller is the events. When some event happens, the application flow continues. This gives flexibility to the application. In Spring, IoC is done by DI which are of three types – setter injection, method injection and constructor injection.
- Beans and Spring Context – In Spring, objects are called as beans and there is a BeanFactory that manages and configures these beans. You can think of the beanfactory as a container that instantiates, configures and manages the beans. Most applications use xml (beans.xml) for the configuration. ApplicationContext which a superset of BeanFactory is used for more complex applications that need event propagation, declarative mechanisms and integration with aspect-oriented features of Spring.
- Read about some more major spring concepts here.
Apache Struts is another robust open-source framework for web applications. It follows the MVC (Model-View-Controller) model and extends the JSP API. In a traditional servlet-JSP approach, if a user submits let’s say a form with his details, the information then goes to a servlet for processing or the control goes over to next JSP (Java Server Pages – where you can write Java code in an HTML). This becomes confusing for complex applications as the ‘View’ or presentation layer should ideally not have business logic.
Struts separate the View, Controller and the Model (data) and provides the binding between each through a configuration file struts-config.xml.
The controller is an ActionServlet where you can write templates for the View and the user data is maintained using ActionForm JavaBean. The Action object is responsible for forwarding the application flow.
The View is maintained by a rich set of tag libraries.
Struts are easy to set up and provides much more flexibility and extensibility over the traditional MVC approach using servlets and JSP alone. It can be a good starting point for your career as a web developer.
Though Hibernate is not a full-stack framework, it completely changed the way we looked at the database. Implementation of Java Persistence API (JPA), Hibernate is an Object-Relational-Mapping (ORM) database for Java applications. Just like SQL, queries in Hibernate are called HQL (Hibernate Query Language).
Hibernate directly maps Java classes to corresponding database tables and vice versa.
The main file in hibernate is the hibernate.cfg.xml file that contains information about mapping Java classes with database configuration.
Hibernate solves the two major problems with JDBC – JDBC doesn’t support object-level relationship and if you ever decide to migrate to a different database, the older queries may not work – meaning a lot of changes – i.e. time and money!
Hibernate provides an abstraction layer so that the code is loosely coupled with the database. Stuff like establishing a database connection, performing CRUD operations are taken care of by Hibernate – so developers need not implement that, hence making the code independent of the database used.
Choose one or more from these beginner and advanced courses to get a complete overview of Hibernate and JPA.
4. Apache Wicket
If you have already worked with JSP, the learning wicket will be a cakewalk. A simple web application framework, Wicket has a component-oriented structure and all you need to know is Java and HTML. Absolutely no XMLs or configuration files!
The main feature of Wicket is it POJO model wherein components are simple (Plain Old) Java Objects having OOP features. These components are bundled together as reusable packages with images, buttons, forms, links, pages, containers, behaviours and more so that developers can customize them.
Wicket is light-weight and you can build applications really fast. It is also easy to unit test code written in Wicket.
5. JSF (Java Server Faces)
Don’t confuse JSF with JSP, which is just a text document that can have static and dynamic content. JSF is developed by Oracle as a part of the Java Enterprise Edition 7.
The default templating system in JSF is the FaceLets. JSF is quite similar to Struts.
JSF can be further seamlessly integrated with AJAX-enabled components to enrich the user experience by adding Ajax events for validations and method invocations.
Check out this LinkedIn course to know more about JSF.
Another Java framework true to its name – wizard. This light-weight framework lets you complete your application very fast because of it’s out of the box support for advanced configurations, logging, application metrics and much more. You can create RESTful web applications that give high performance, are stable and reliable.
Dropwizard is especially magical because it brings together a host of libraries like Jetty, Guava, Jersey, Jackson, and Metrics amongst many others from the Java ecosystem into one framework and gives you a light-weight and lean application.
Since there are integrated libraries for all the configurations, security and performance-related tasks, all you need to do as a developer is building your business logic.
Dropwizard is an open-source framework that is bundled with libraries and you can easily set it up with Eclipse IDE and create a simple project to learn (Believe me, you can learn Dropwizard on your own!). The basic tutorial from Dropwizard website will help you through each step.
Grails is an easy to learn full-stack framework much suitable for those who are just beginning their programming career. While Grails is a web framework written in Groovy programming language, it runs on Java platform and is perfectly compatible with Java syntax. This framework is based on the MVC design pattern.
Groovy is similar to Java which some more features added when compared to Java. It is very easy to learn Groovy if you already know Java.
Similar to JSP, in Grails, the rendering technology is GSP (Groovy Server Pages). Creating tags for the View in Grails is simple and easy. It also uses GORM which as you might have guessed is the ORM implementation used in Grails. You can also directly use Hibernate instead of GORM. Grails has built-in support for RESTful APIs thus making it easy to create such services.
Here comes the best part – you can integrate your existing java code with Grails. If you have a mix of Groovy and Java code in your application – it will work just fine!
The best way to learn Grails is to set up your own development environment using any Java IDE like Eclipse, NetBeans etc… and follow any of these tutorials to build your first web application.
ATG is a web commerce platform written in Java. It is a customizable and configurable framework, particularly useful for websites related to e-commerce. The product is owned by Oracle and supports both B2B and B2C applications that are complex and huge. For small scale applications, it could be costly, however. If you are getting into developing e-commerce websites, ATG is a good framework to learn and will enrich your technical as well as domain knowledge.
ATG platform can run on three servers – Oracle Weblogic, IBM Websphere, and JBoss.
There are 3 main layers in the framework –
- The Dynamo Application Framework – it is the base layer that provides a development environment based on JavaBeans and JSP. There are standard ATG classes for all the common functionalities and even custom Java code can be created and assembled out of component beans by linking them through configuration files.
- The Personalization module – This is where the content for each user is customized dynamically. This module helps control and maintain user-profiles and business rules that define what content is to be shown to a particular user. This layer also supports targeted emails.
- The Scenarios module – This module further enhances the capabilities of the personalization module by introducing time-sensitive, event-driven campaigns that manage interactions between site visitors and the content for a period of time. For example, limited time offers, exclusive deals for certain members etc…
ATG is an extensive framework and you need time and patience to learn it. Several big companies like Walmart, Macy’s, BestBuy, ASDA and more have their website built on ATG.
Play is a slightly conventional and unique type of framework that follows the approach of convention over configuration. It is based on the MVC pattern and is an open-source web application framework. Apart from Java, you can write Play web applications in Scala.
Play is similar to Django or Ruby on Rails or ASP.NET architecture and doesn’t necessarily follow J2EE web standards.
Some features of Play are –
- High performance because of the asynchronous processing
- No container, no states and built on reactive principles
- Uses statically-typed language, so most errors are caught during compile time saving a lot of mistakes early in the development life-cycle.
- Scala explores true OOP along with some functional programming concepts. Its compatibility with Java makes for an excellent and powerful system.
- With Play2, a new powerful build system sbt has been released which makes it easy to integrate with Maven projects as well as create simple JAR files.
- Extensive relational database access libraries for common functionalities are in-built.
10. Apache Hadoop
Though Apache Hadoop is not a full-stack framework, it provides a software framework and works on the MapReduce programming model. These utilities can easily handle huge volumes of data (Big Data), store, analyse and process them to provide faster and more efficient results.
I have included Hadoop in this list because it is the ‘thing’ of today with Big Data gaining prominence.
Hadoop helps in distributed data storage and processing using the master slave design pattern. The Hadoop HDFS (Hadoop Distributed File System) layer of the master node (namely NameNode) has the data node. The MapReduce layer has the JobTracker and the tasktracker. The slave nodes have the Data node and the taskTracker respectively.
HDFS divides the files into set of blocks and these are replicated across the cluster.
If you want to familiarize yourself with big data and data science – Hadoop is your place to start. Learn Hadoop easily through these tutorials.
Get started with learning GWT here.
Vaadin is a flagship product and also a platform where developers can do HTML5 web UI implementation using Java. It is an open-source platform that includes the Java web framework and a set of web components along with application starters and tools. These web components form the core of Vaadin and can be customized leading to high performance and versatile code for desktop and mobile apps.
Vaadin flow is the actual Java framework part of the Vaadin platform that takes care of the client-server communication as well as routing. With Vaadin flow, you can write your web application completely in Java without the fuss of JS or CSS. The UI components take care of the browser activities of the user using automated communication to and forth browser and server. You can easily integrate Vaadin components into any IDE that you are using plus it is a cross-platform framework, so no need to worry about migrating the code into a different platform.
It is a whole new approach to build Java applications so that you can concentrate on the presentation layer alone without worrying about client-server communications. It also has Data Binding API that maps UI components to the database using type-safe Java code and abstraction layers so that you can build reusable components in UI using HTML templates and Java both.
Another masterstroke from Apache, Spark is an open-source web development framework which has similar features as Spring, Play and JAX-RS, but is more powerful and doesn’t follow the traditional MVC design pattern.
It is a micro-framework and a domain-specific language for Java focussing on the speed of development. It needs very less configuration and coding. It is 10 times faster than Hadoop in terms of data processing because of in-memory computation. A completely dynamic framework, Spark supports lazy initialization and real-time data processing.
It is also easy to integrate with Scala and R which are programming languages focused on data science and big data. The primary objective of Spark is processing huge data and also supports advanced analytics with SQL queries, machine learning and graph algorithms.
Don’t think that Spark can replace Hadoop – it can be an extension to the features that Hadoop offers – learning both these frameworks will give you an edge over others if you are getting into Data Science field.
A low-code platform for developing web applications in a fast manner, you can get your business applications up and running in record time. It consists of business components that make building even complex applications easy and hassle-free for developers. Extensible, customizable and OO in true sense, OpenXava uses Java classes as its core to model the business problem. Such a model-driven development approach ensures encapsulation. Developers only define the model as plain annotated Java classes and the necessary functionalities are all generated during run time.
The structure and philosophy of OpenXava follow a business component architecture as opposed to the traditional MVC architecture. Here everything is a business concept and all the artifacts contributing to a certain business concept are in the same place be it the associated View, Model or Controller.
You should definitely read the concept behind this language here before you learn this framework.
Developed by Eclipse, Vert.x is an event-driven application framework that uses many languages like Java, JS, Groovy, Scala and more. It is thus polyglot in nature. It relies upon the asynchronous programming model thus making the applications non-blocking and free from multi-threading.
Vert.x can be said as more of a toolkit that provides APIs in multiple languages to perform asynchronous tasks that all the web applications need – logging, authentication, monitoring, DB connectivity, multi-cluster support etc… There are 2 main concepts in Vert.x –
- Verticle – Just like any other asynchronous model, there is an event loop which has events like messages, network buffers, HTTP request, etc. Each event from the event loop is processed by the Verticle.
- Event bus – Different verticles communicate with each other using the event bus. This is done through asynchronous message passing. Event bus can perform different types of messaging like point to point, broadcast and request-response.
The best thing about Vert.x is its non-blocking nature which makes the web applications highly performant. The framework can be used for any application – small, medium or large-scale. If you already know Node.js, you will appreciate Vert.x more, because it has all the features of Node.js plus the benefit of Java Virtual machine which makes for a powerful and robust combination.
Conceptually, Tapestry is similar to JSF and Wicket. It is an open-source, cross-platform, component-based web application development framework which can create highly scalable applications. Built upon the rich Java Servlet API, it works on any container or application server. Tapestry is a true Object-oriented framework because you create HTML pages using pure HTML templates or plain java class (objects). There is almost no XML configuration required, Tapestry rather uses annotations, thus making the code simple and easy to manage.
With Tapestry, application down-time is minimal because any changes even to a Java class can be hot-swapped without requiring a server restart. Tapestry also takes care of URL construction and redirections. Unlike other frameworks, here the framework adapts to the code and not vice versa.
Some of the out of the box functionalities of Tapestry are – file upload, pagination, field validations, date and calendar logics, internalization, showing pop-ups etc…
It is easy to integrate Tapestry code with back-end frameworks like Spring, Hibernate, etc… and testing frameworks like Selenium.
Jersey is a web services framework to create RESTful services and supports JAX-RS APIs. It greatly simplifies the development of RESTful services through useful features and utility functions. Jersey provides a sort of abstraction layer so that developers need not worry about the low-level implementation of client-server communication and can concentrate on the main web service functionality.
A striking feature of Jersey, as opposed to any other RESTful frameworks, is that it allows for Chunked output i.e. the server can send back a response to a client in parts or chunks. This is useful when a large data has to be sent and data chunks can be sent while the entire response is prepared.
Jersey also comes with easy testing infrastructure. You can write lightweight integration tests that are primarily based on Junit. It is also easy to integrate the tests with Maven environment. All you need to do is add the dependency in your pom.xml.
OSGi or Open Service Gateway initiative defines a component-based system. It is a popular Java framework where each component is called a bundle. Each bundle has an independent lifecycle and is not dependent on other bundles. Consider the bundle to be jar file with OSGi-specific headers. Bundles have to explicitly declare the packages they need access to without which the OSGi platform will not start.
Bundles use the JVM-level service registry to discover, publish and bind bundles as services. This is the essence of OSGi – for a modular application architecture promoting adaptability and quick changes without much application down-time (run-time flexibility).
OSGi is mainly popular because of its easy integration with eclipse and maven-based projects.
OSGi has some good concept and benefits, yet because of individual independent bundles versioning could be an issue. This could be one major disadvantage of using this framework over others. However, it is worth investing some time on this framework because of the benefits of modularity and isolated class loading that are important concepts for a developer. Read this article to know more about what you should and shouldn’t be learning about OSGi.
Drools is a popular Business Rules Management System. It has a Business Rules Engine (BRE), authoring, a rules management application and runtime support for Decision and Notation models. The rules management app is called as the Drools workbench. The project is backed by RedHat and JBoss. With Drools, developers can easily separate the data from business logic. The two main steps in Drools are –
Authoring – Creation of rule files
Runtime – where you execute the rules
The most important feature of Drools is that new rules can be removed and added at any time without restarting the server.
Drools is apt choice for applications that rely on a lot of conditions for some action to happen. For example, to check if a person is eligible for upgrading his plan or not, there are certain set rules – for example, is the customer existing, the customer’s bill amount is greater than the certain limit and so on. These rules can be defined as a decision table rather than hard coding them in the code. Any changes would then not need another build, complete testing or redeployment!
A free software by Apache, MyBatis is a persistence framework in Java where Java methods are mapped with SQL statements, unlike ORM which maps Java objects to tables in the database. The mapping engine maps the SQL results into object trees using XML descriptors or annotations in a declarative way.
In a lot of ways, MyBatis is better than JDBC and Hibernate. MyBatis can dynamically generate SQL statements separating them from the code. It also offers query caching for easy access. The API is very simple and you need not be an expert in SQL or database to be able to write MyBatis code.
MyBatis is a good alternative to Hibernate and JDBC when your application is not too complex and you want simple out of the box features like database connectivity, transaction management, loading the database driver, managing and releasing connections and so on done by the framework. MyBatis can also be integrated easily with the Spring framework.
21. Apache Mina
Apache Mina is a network application framework with which developers can easily create highly scalable and performant network applications. Whether you use TCP/IP, UDP, LDAP, NTP, DNS etc… or a custom protocol, Mina has unified APIs for all the transports. The framework can provide high-level and low-level network APIs. Mina completely handles the I/O operations helping the developers to concentrate fully on business logic and other application needs. It is easy to test the code written with the help of mock objects. You can easily learn Mina using the Eclipse IDE. It can be integrated with popular frameworks like Spring and PicoContainer making it a popular choice for network applications.
MINA is better than SOAP and is more stable and reliable. It has a rich networking library to handle concurrent threads.
Learn more about Apache Mina from their official page.
There are many other frameworks which are not full-stack or web development frameworks but are useful in every application – like log4j for logging, Junit, and Selenium for testing and so on. It is essential to know about these though you can just learn them on the go along with the other frameworks that you have seen in the above list.
Wikipedia provides a complete list of Java frameworks, libraries, and tools that can be overwhelming sometimes. The best framework for your application should meet your business requirements, provide a certain level of flexibility and optimum performance and be easy to maintain and absorb changes. For example, for a full stack web development framework, if something has to be changed, it should least impact the application i.e. you shouldn’t have to build and deploy the application again for small changes. Just a configuration change should do the magic. Such applications save down-time and provide flexibility. Choose your application framework wisely to enjoy the features that Java provides.
People Also Read:
- Best Python Frameworks you should Know
- Best PHP Frameworks for Web Development
- Top 10 Web Development Frameworks in 2019
- Core Java Cheat Sheet | Download PDF
- Best Way to Learn Java
- Top Java Certification Programs
- Best Java Interview Questions in 2019
- Top Java IDEs and Source Code Editor
- What are the Major Features of Java?