The Internet of Java Things

3 mins read

The Internet of Things (IoT) has become a hot topic over the last few years. Organisations like Gartner predict that there will be nearly 26billion connected devices by 2020. Moore’s law of increasing transistor density has an inverse, which is that the same complexity chip also becomes exponentially cheaper. The result of this is that the cost of providing computing power and network connectivity in pretty much any device has now fallen to the point that it is not an issue when considering the bill of materials. To demonstrate this, consider the recently announced Raspberry Pi Zero, which has a CPU clocked at 1GHz and 512Mbyte RAM and can drive a quite usable desktop computing environment. All for only $5.

Just including the necessary hardware is only part of the story. To make processing power and connectivity of any use there must be software applications. This is where Java can provide a range of advantages for IoT application development:

  • “Write once, run anywhere”: By compiling to bytecodes rather than native machine instructions it is the Java Virtual Machine (JVM) that is responsible for running application code. Once the JVM has been ported to a particular hardware platform any Java code can be run on it. No more endless porting of applications each time there is a new revision of the hardware.
  • Automatic memory management: When programming in C and C++ the developer is responsible for all memory management, allocating memory through APIs like malloc and deallocating it through free.If memory is not explicitly deallocated the application exhibits a memory leak. Assuming memory continually needs to be allocated the application will eventually fail when free memory is exhausted. In Java all objects are allocated by the JVM in a heap, references to objects are tracked and when no longer required the memory is reclaimed by the garbage collector, which runs automatically in the background.
  • No explicit pointers: Again, using languages like C and C++ has drawbacks because of the use of pointers to reference explicit memory addresses. Buffer overrun security flaws and references to invalid memory addresses causing application crashes are both consequences of this. In Java you only have implicit pointers to objects. These cannot be manipulated, other than to point at a different (valid) object. This eliminates a wide range of potential application flaws before you even start writing code.
  • Comprehensive Libraries: The current release of Java, JDK 8, has over 4000 classes available by default to developers. This rich set of functionality means developers are saved a lot of time not having to reinvent the wheel by writing their own list class, for example. If more application specific APIs are required there is normally a third-party library available; most of the time this will be both free and open source.
  • Flexible Deployment: A comprehensive set of libraries is wonderful, but in an embedded environment can sometimes mean the runtime takes up too much storage space. To address this the current version of Java (JDK 8) supports three compact profiles. These allow subsets of the standard APIs to be used reducing the amount of space required by eliminating unnecessary packages. In JDK 9 a modular runtime system (project Jigsaw) will be introduced to Java giving even greater flexibility for the runtime deployment configuration.
  • Remote management is built in: Java has a set of Java Management Extensions (JMX), which includes MBeans (Managed Beans). This provides an architecture that can remotely manage resources dynamically at runtime. This is very useful when dealing with devices that are typically widely distributed and can be hard to get to physically.
  • A huge pool of trained developers: According to some estimates there are nine million Java developers in the world. Regardless of exact numbers it’s fair to say that there are millions of developers trained in Java. Most Universities use Java as a teaching language for object-oriented techniques because of its appeal to employers and practicality. What this all means is that when you want to staff a project being developed in Java you have a big pool of talent to draw on.
  • Powerful Development Tools: Having skilled developers is good, but for them to be really productive they need great tools. Again, Java has what’s needed. There are several great integrated development environments (IDEs) like Eclipse (Azul is a member of the Eclipse Foundation), NetBeans and IntelliJ, all of which have free and open source versions. In addition, there are many useful tools covering all aspects of Java software development with free and open source versions: VisualVM, JUnit, Jenkins, Gradle and GC Viewer to name but a few.

At Azul our business is JVMs and we’ve been using the source code from the OpenJDK project (which is the reference implementation of the Java SE standard) to build binary distributions of Java, called project Zulu. As well as building distributions for servers and desktops we also have embedded versions available. Initially we produced a version that would run on devices using both 32 and 64-bit Intel processors. This runs on development boards like the Edison and Galileo.

At Embedded World in February this year we announced JVM support for ARM v6, v7 and 32-bit v8 architectures. This means all versions of the Raspberry Pi are supported (although the Raspberry Pi 3 uses an A53 core, which is a 64-bit v8, all v7 code will run without change on this).

In addition to supporting the listed processor architectures the Zulu Embedded JVMs also support a wide variety of operating systems:

  • Linux, including Yocto, Ubuntu and Wind River (Zulu is also available through the Wind River Marketplace).
  • Windows 32 and 64-bit, including the Windows 10 IoT Core

The key thing about the Zulu Embedded distributions is that they are built from open source code and are fully compliant with the Java specifications (as defined through the Java Community Process), having passed the relevant Technology Compatibility Kit (TCK) tests. This means that there are no licensing costs to pay when using Zulu Embedded; if you want support from Azul for your project we’ll not only help with tailoring the Zulu JVM to your specific hardware configuration we can also offer flexible support plans that can be per device, per user or flat rate depending on what makes most sense for you.

When looking at developing new IoT devices the question you should be asking is not, “Why would I use Java for this?” but rather “Why would I not use Java?”

Author profile:
Simon Ritter is deputy CTO at Azul Systems