Monday, March 16, 2015

Java ME 8 and the Internet of Things

Embedded systems are computer systems embedded into complete devices, whose dedicated functions reside within a larger mechanical or electrical system. Typically used in both industrial and consumer applications, embedded systems are entering the limelight with the Internet of Things (IoT). For developers just getting started with IoT, this article is a guide for learning more about the technologies that comprise Oracle's IoT platform: Java ME 8, Java ME Embedded, Java SE Embedded, and Java Embedded Suite.
In 1991, Mark Weiser, then head of Xerox's Palo Alto Research Center (PARC), attempted to capture the coming age of ubiquitous computing. Noting that "[t]he most profound technologies are those that disappear," Weiser described the various thought and technical experiments conducted by his colleagues at PARC, as they sought a new way of thinking about computers as embedded systems. Their vision, which might have seemed as fantastic as a hovercraft in 1991, is quickly becoming more commonplace today:
Sal awakens: she smells coffee. A few minutes ago her alarm clock, alerted by her restless rolling before waking, had quietly asked, "Coffee?," and she had mumbled, "Yes." "Yes" and "no" are the only words it knows [...]
At breakfast Sal reads the news. She still prefers the paper form, as do most people. She spots an interesting quote from a columnist in the business section. She wipes her pen over the newspaper's name, date, section, and page number and then circles the quote. The pen sends a message to the paper, which transmits the quote to her office [...]
Once Sal arrives at work, the foreview (in her car) helps her to quickly find a parking spot. As she walks into the building the machines in her office prepare to log her in ...
The embedded devices in Weiser's workday morning scenario use sensors to track a human user's interactions, and wireless connectivity to orchestrate a response: Sal's bed, alarm clock, and coffee maker are all connected to ensure that her first cup of coffee is underway before she rolls out of bed. For Weiser and his colleagues, this was calm computing; today we might call it the Internet of Things (IoT).

IoT overview

If there is one defining characteristic of IoT, it is interoperability, or the coordination of multiple devices. As observed in the above scenario, IoT uses sensors to collect data (in that case about Sal's interactions in her environment) and wireless connectivity to orchestrate a response. IoT is built on a confluence of technologies, including new and old hardware platforms, big data, cloud computing, and machine-to-machine (M2M) computing. APIs are the necessary glue, bringing all of these moving parts together.
Most importantly for Java developers, Java is key to many of the emerging IoT technologies already, and Oracle has committed to making Java a leading platform (if not the platform) for IoT. Java ME 8 breathes new life into Java's small device technology, extending it with a differentiated line of embedded Java platforms.
The next sections will introduce the technologies that comprise Oracle's IoT platform; follow the links to learn more about Java ME, Java ME 8, and the three embedded frameworks: Java ME Embedded, Java SE Embedded, and Java Embedded Suite.

Java ME

Java Micro Edition was originally intended to address the constraints associated with building applications for small devices. Based on Java SE, Java ME (or J2ME, as we knew it in 1999) was the platform for Java applications running on small devices with limited memory, display, and power capacity. Today it is used to develop embedded systems, ranging from industrial controls to mobile phones (especially feature phones), to set-top boxes and Blu-ray players.
Developers working in Java ME can choose from multiple configurations, profiles, and optional packages:
  • configuration provides the most basic set of libraries and virtual machine capabilities for a broad range of devices.
  • profile is a set of APIs that support a narrower range of devices.
  • An optional package is a set of technology-specific APIs. The Wireless Messaging API is one example. Check out Oracle's optional package primer to learn more about optional packages.

Configurations and profiles

In time two configurations have emerged: Connected Limited Device Configuration (CLDC) is the configuration for small devices, and Connected Device Configuration (CDC) is the configuration for more capable mobile devices such as smartphones and set-top boxes.
Java ME profiles sit on top of configurations, defining higher-level APIs of use to particular applications. Mobile Information Device Profile (MIDP), for instance, sits on top of CLDC and provides user interface, networking, and persistent storage APIs. Applications that run in a CLDC/MIDP environment (such as games) are known asMIDlets.
For CDC, there are three profiles, Foundation, Personal Basis, and Personal:
  • The Foundation Profile is a set of Java APIs tuned for low-footprint devices that have limited resources and don't need a graphical user interface (GUI).
  • The Personal Basis Profile is a superset of the Foundation Profile APIs and supports devices with lightweight GUI requirements. This profile comes with a framework for building lightweight GUI components and supports some Abstract Window Toolkit (AWT) classes.
  • The Personal Profile extends the Personal Basis Profile with a GUI toolkit based on the AWT. It provides a complete Java ME application environment with full AWT support and is intended for higher-end devices like PDAs, set-top boxes, game consoles, and so on.
Applications that run in a CDC/Foundation/Personal Basis/Personal environment (such as Blu-ray movie menus) are known as Xlets.

Java ME 8

In late 2012, Oracle embarked on an ambitious project to deliver a major update of the Java ME platform standard. Two Java Specification Requests (JSRs) were designed to meet current market requirements for embedded devices and prepare Java ME for future Java platform specifications: JSR 360 (CLDC 8), an evolutionary update to CLDC 1.1.1, would bring the virtual machine, Java language, and libraries up to date with Java SE 8. JSR 361 (Java ME Embedded Profile/MEEP 8) would updateInformation Module Profile - Next Generation (IMP-NG).

CLDC 8 and MEEP 8

CLDC 8 is based on JSR 139 (CLDC 1.1) and aligns the core Java ME virtual machine, language support, libraries, and other features with Java SE 8:
  • The virtual machine has been updated to comply with version 2 of the JVM specification.
  • Newer Java SE language features such as generics, assertions, annotations, and try-with-resources are now supported.
  • New libraries such as Collections, NIO subset, and Logging API subset are now supported.
  • A consolidated and enhanced Generic Connection Framework for multi-protocol I/O is supported.
MEEP 8 updates the original IMP-NG specification to provide a powerful and flexible application environment for small embedded Java platforms. The specification builds on CLDC 8 with the following features:
  • A new, lightweight component and services model
  • Shared libraries
  • Multi-application concurrency, inter-application communication, and event system
  • Application management
  • API optionality to address low-footprint use cases
MEEP 8 gives embedded application developers a modern application environment that facilitates developing and deploying embedded solutions that are modular, robust, sophisticated solutions that have been optimized for a wide range of use cases and devices.

Java Embedded

Java Embedded is an outgrowth of Java ME and Java SE, a suite of three platforms that specifically target embedded devices. Each of these products delivers a very specialized and optimized Java virtual machine and provides the means to update the installed software and services (for instance by using OSGi). Below I describe Java ME Embedded, Java SE Embedded, and the Java Embedded Suite.

Java ME Embedded

Java ME Embedded actually consists of two versions: Java ME Embedded and Java ME Embedded Client.
Java ME Embedded is a Java ME CLDC implementation that provides a robust and flexible application platform with dedicated embedded functionality for always-on, headless (meaning no graphics/user interface), and connected devices. System designers and developers can use Java ME Embedded to create sophisticated, small embedded solutions that leverage the benefits of the Java language, runtime, and ecosystem while meeting tight system resource targets. Oracle Java ME Embedded can be used by devices with less than one megabyte of memory.
Java ME Embedded Client is a Java ME CDC implementation that has been scaled down to fit the limitations of resource-constrained devices and optimized for low-to-mid-range embedded systems. Although this product offers a small footprint, it still provides most of the Java language and runtime features that Java developers know and are accustomed to with Java SE. Java ME Embedded Client can be used by devices with less than 10 megabytes of memory and no graphics.

Java SE Embedded

Java SE Embedded is a full-featured implementation of the Java SE platform that's been optimized for embedded systems. Version 8, the current latest release of this platform, includes the following features:
  • New Java SE 8 language features to improve developer productivity
  • Compact profiles and tools to create customized, space-optimized virtual machines
  • 50% better performance than previous versions thanks to Java SE 8
  • Great-looking GUI applications with GPU-accelerated JavaFX
  • Tools for detailed runtime monitoring and after-the-fact incident analysis
Note that Java SE Embedded 8 can be used by devices with a minimum of 11 megabytes of storage. Download Java SE Embedded 8 for ARM, Power Architecture, and x86 platforms.

Java Embedded Suite

Java Embedded Suite is the final offering in the Java Embedded family. This suite of tools adds enterprise-type features to the Java SE Embedded runtime, enabling applications to do the following:
  • Store data in a Java DB relational database.
  • Host GlassFish servlet-based Web applications, for example, to give secure remote access to device data and operations.
  • Host and access RESTful Web services with Oracle's Jersey implementation of the JAX-RS specification.
Essentially, Java Embedded Suite combines Java SE Embedded 7 (which provides a runtime for Java applications) with Java DB (which provides a database to store local content securely), GlassFish for Embedded Suite (which provides an application server for Web pages), Jersey Web Services Framework (for hosting and accessing Web services), and Event Processing for Java Embedded (which handles real-time event processing, and which is an optional component).
Download Java Embedded Suite for ARM or x86.

Conclusion

Oracle has positioned Java ME and related technologies to meet the challenges of developing for embedded devices, with IoT as its ultimate goal. This article presented a short primer on Java ME and then introduced you to Oracle's Java ME 8, Java ME Embedded, Java SE Embedded, and Java Embedded Suite products.
For programming tutorials and best practices that will help get you started with IoT fundamentals, visit the Java MEMIDP, and Embedded Java programming pages on JavaWorld. To learn more about Oracle's strategy for IoT and Java's place in this strategy, check out the various articles, videos, white papers, and brochures on theOracle Internet of Things information page.


This story, "Java ME 8 and the Internet of Things" was originally published by javaWorld.

No comments:

Post a Comment