Photo: Daniel Chetroni – shutterstock.com
“Write once, run everywhere” – was once the mantra of Java makers. Nowhere is their success more evident than in the world of embedded systems. For teams developing software for small devices and hidden computers, it’s an advantage to be able to write one version of a Java program and run it anywhere. In many cases, developers don’t even know that much about the CPU that will be used in the final product – and they don’t have to. The flexibility of Java also helps product teams in the long run: the second, third or fourth generation of a product can eventually run on different chips. Even then, the software can usually be modified with little or no extra effort.
Many frameworks are used today to write embedded Java applications. Some are more general tools intended for use on many machine types. They are often a good starting point for teams building new applications. Other frameworks are developed for a specific device or device family. They can contain a programming base as well as functions that support the devices (or other products) on which the application is to run. The most common example of this type of embedded Java framework is probably Android, which developers use to create applications for, say, Android smartphones, Chromebooks, or TV sets.
We’ve put together the eight best Java frameworks for embedded development for you. They all take advantage of Java’s stability and bandwidth and include third-party libraries. These frameworks adapt traditional Java techniques and approaches for the embedded market, making them faster and lighter.
Android is probably the best known embedded Java framework. It was the foundation for Google to deliver apps for smartphones – and to compete with Apple. Much of the original Android codebase has been made open source. Many other types of devices now also support Android applications – Chrome OS is just one example. Writing Android apps is an easy way to reach all users of these devices. Device manufacturers can also open their products to third-party developers.
Some developers only work with the basic Android libraries, which are more than enough for many programs. Others use frameworks based on Android. The most popular include:
A common feature allows developers to reuse themes for other platforms such as iOS. For example, Flutter focuses on six different platforms.
This framework makes it easier for developers to write high-level Java code that addresses the interfaces commonly found in embedded systems. Popular examples include Raspberry Pi and Orange Pi. With Java Embedded Framework, you don’t need to have low level programming skills needed to interact with hardware interfaces such as
The developers of the framework have (most of) already done that for you.
Java Embedded Framework is divided into several main modules. The main module connects directly to the Linux OS layer that controls the board. This makes it easier to use pure Java to bind many OS-level tasks. Drivers are also available for major hardware components.
Oracle event processing (PDF)
One task of embedded devices is data acquisition. In factories, for example, they are used to monitor production and check for deviations.
Oracle’s Event Processing Framework is a lightweight version of Oracle Event Driven Server. Allows devices to collect, filter, and forward events as needed.
Some of the configuration syntax is based on SQL, so it’s relatively easy to learn. The framework’s event processing model can also examine event streams for correlations and other patterns.
If you want an embedded device to respond to RESTful events, Jersey is a good option. The framework is optimized to juggle the inbound and outbound JSON packets. It expands on that JAX-RS Toolkit. Software architects also appreciate the solution because it is one of the best ways to automate communication with devices.
Jersey offers a number of additional features, including the ability to split answers. This means that data is stored and then sent in one large chunk (“chunk”). This technique is especially useful for devices that are not always connected to the Internet. In addition, this also reduces the load on central servers that have to communicate with many devices.
When it comes to Vert.x, many have the comprehensive web application development framework in mind. One of the advantages is its modularity: the Vert.x core contains the main code to write services that allow interaction. The Vert.x framework’s network and file system protocols allow streams to process incoming and outgoing requests. Some Vert.x modules are ideal for embedded tasks:
-
For example, the OpenAPI and API Service libraries perform many of the tasks required to support an API.
-
the GraphQLlibrary contains the routines needed to support the correct calls.
These libraries mainly focus on developing web applications and services, but can also be used for simpler communication tasks.
When the goal is to build a simple, powerful RESTful web service, many Java developers turn to Dropwizard. The framework is also a good choice for embedded applications. To control and configure devices, you can use the web service API, other devices can access the service through the API. The service is managed via static HTML pages with some JavaScript.
Dropwizard is also divided into a number of smaller modules that can be chosen depending on the functionality required:
-
People interacting with your services can use the modules forms or vision to use.
-
Authentication is generally a good idea and appropriate Dropwizard module provides support for the Basic and OAuth2 protocols.
Any application that needs a robust network layer can rely on Apache Mina to handle the various NDP or TCP connections securely and reliably.
The code builds on the new IO classes (Java NOK) on – Developers can handle incoming and outgoing data in a more abstract way. The code for this is largely event-driven, so developers don’t have to worry about the network interface.
Some embedded processors have additional layers of security to protect sensitive data. Oracle’s Java Card supports running multiple applications within such secure enclaves. The CPUs it uses are often slower and have less storage space – so the Java Card framework is accordingly slim so that it can also run smoothly with fewer resources.
Although this article is about embedded development frameworks, in practice more and more developers are creating web applications for embedded systems. Smaller devices may not be as powerful, but often have enough RAM and CPU power on board to run a web server application for a few clients. Applications that are not intended for a billion users on the open internet can easily run on an embedded system. This is often a good solution because users connect to the device through a web application, while developers can use all the standard features of a simple website.
Many common web application frameworks also work surprisingly well on small devices. This is partly due to efforts to downsize and simplify the server side of Java web applications. Newer, lightweight frameworks like
are all reliable choices. Some embedded developers even manage with older, heavier frameworks – e.g
The latest frameworks come from a time when servers were much less powerful. They are well suited for scenarios where a user needs to interact with the software and the embedded device is relatively powerful.
Some developers don’t need an embedded framework – they use the required libraries and functions of a standard Java version:
-
Java Micro Edition comes in several versions, some of which are explicit for embedded systems are matched. They provide important Java libraries, such as OAuth for authentication and JSON for parsing and composing messages.
-
Oracle Java SE Embedded is a Java standard version designed for the embedded world. Oracle supports many different types of devices by providing standard binaries. For example, the Raspberry Pi (and some other embedded systems) is already predefined. Other key market segments such as smartphones and TVs are also supported. For simple embedded Java development projects, a standard Oracle download may already have everything you need.
(FM)
This post is based on an article from our US sister publication Infoworld.