/* jquery */ /* jquery accordion style*/ /* jquery init */

1 August 2017

Java 9 and the Raspberry Pi

The Java coding language has been included in the Raspberry Pi's official Raspbian distro for some time now. Java 9, the latest incarnation of the language due for release in Autumn 2017, introduces raft of enhancements.

In this post I'll touch on some Pi-centric key aspects of Java 9, namely the new Java Shell, modularity and jlink, plus CPU support.

Java Shell - about time

Python has always had a read-eval-print loop (REPL) command-line option. It's a great way for newbies to get to grips with the coding basics and the language syntax.

Until now Java hasn't had a REPL option. But version 9 comes with jshell. Key features are: instant feedback, optional semicolons, a range of pre-imported libraries (like io, math, net and util) and a handy collection of slash commands to load, save, manipulate and analyse source code.

You can experiment with shell now in the Java 9 early release.

Modularity and JLink - smaller and faster

As your Java project grows the number of libraries and their dependencies starts to get increasing complex. This can mean your programs are slower to load and execute. Project Jigsaw set about changing this picture by breaking things up into a collection combinable blocks for system, jdk, source code and binary runtime elements.

This work lead to Java 9's new requires keyword, which helps to identify library dependencies. When compiling a runtime image this information is used by 'jlink' to assemble and size-optimize a binary runtime image.

CPU Support - not all Pi models

Java 9 takes advantage specific CPU instruction sets commonly found in modern 64-bit processors, like the ARM v7/8 CPUs and x86 range. This move will help improve runtime performance.

However, as of today, this does limit Java 9 to the Raspberry Pi 2 and Pi 3 boards. Owners of model As, Bs and Zeros, with their older ARM v6 processor chips, will therefore have to keep using Java 8.

Read all my Java coding posts

No comments: