Вы находитесь на странице: 1из 5

COMMUNITY

(embedded )

TOP TEN For many years now,


we’ve been promised the
Internet of Things—with

REASONS
everything from light-

JAVA IN ACTION
bulbs to cars all networked
together with built-in

FOR USING
“intelligence.” The com-
bination of Moore’s Law
and economies of scale is

JAVA IN
finally making this a real-
ity. For example, Philips

JAVA TECH
recently announced that it
would be selling internet-

EMBEDDED
enabled lightbulbs through
the Apple store. For these
networked, programmable

APPS
devices to be really useful,
they need applications to

ABOUT US
collect, process, and trans-
mit data. Traditionally,
code for embedded sys-
Learn why Java is the best language tems has been written
for the Internet of Things. in assembler or C, but
for the rapid explosion
BY SIMON RITTER
of programmable, con-
nected devices, we need
something better: Java.
What makes Java the best
language for embedded
devices? Here are ten great
reasons (with thanks to
Roger Brinkley’s blog entry
for inspiration): blog

ART BY NICHOLAS PAVKOVIC, PHOTOGRAPHY BY BOB ADLER 26


ORACLE.COM/JAVAMAGAZINE  ///////////////////////////////////  JANUARY/FEBRUARY 2013
COMMUNITY
1
nication, and a ZigBee API, to name a sor and OS will change significantly
WE ALREADY HAVE A WHEEL; LET’S
few. Many of these libraries are open from the previous release of the prod-
NOT KEEP INVENTING NEW ONES.
sourced and can easily be integrated uct. Migrating applications written in
into new embedded applications. assembler or C to a new platform can

JAVA IN ACTION
Java SE 7 has almost 4,000 standard be time consuming, costly, and error

2
class libraries covering everything prone. From the very beginning, Java
“SEGMENTATION FAULT” IS NEVER
from collections through concurrency GOOD, SO WE’LL JUST AVOID IT. has been write once, run anywhere.
to networking. Having this enormous Porting code in Java is a non-event. As
collection of standard APIs means long as none of the APIs used by the
significantly less time spent rewriting One of Java’s strengths, and one of the application have changed, it’s simply
standard functionality for embedded things that has made it so popular as a a matter of redeploying the existing
applications. While smaller-footprint programming language, is how robust class or Java archive (JAR) files. When

JAVA TECH
parts of the Java platform, such as application code is. Languages such moving to a newer (and therefore
Oracle Java ME Embedded, don’t have as C and C++ use explicit pointers to better-performing) version of Java, all
as many standard classes by default, reference memory. In Java, all object that is required is a simple recompile.
they still have a wealth of functional- references are implicit pointers that

4
ity available. Many of the Oracle Java cannot be manipulated by application
LET THE VIRTUAL MACHINE TAKE
ME Embedded APIs are targeted at code. This avoids potential problems, CARE OF THE MUNDANE STUFF.
the needs of embedded systems: such as buffer overruns and memory

ABOUT US
for example, the device API provides access violations, through incorrect
standardized ways of working with pointer calculations. Situations such as The Java Virtual Machine (JVM) pro-
low-level protocols such as Serial these can cause an application to stop vides a wealth of benefits to embedded
Peripheral Interface abruptly. In embedded systems, these developers that they don’t get with
ONE FOR ALL (SPI) and Inter- types of errors can be much harder to natively compiled code.
Porting code in Java Integrated Circuit track down because often there is no Memory management is all handled

is a non-event. As (I2C). However,


Java’s API power
device such as a screen where error
messages can be displayed.
automatically by the JVM; memory is
allocated by instantiating an object,
long as none of the doesn’t stop with rather than having to use explicit calls
APIs used by the
3
the classes available to library functions such as malloc.
ONE PLATFORM RUNS
as part of the plat- Developers don’t have to keep track of
application have form. Because Java
THEM ALL.
object references and explicitly de-
changed, it’s simply a is such a popular
language, develop- Unlike desktop machines or even serv-
allocate memory either; the garbage
collector handles all this. This substan-
matter of redeploying ers have created ers, embedded systems vary widely in tially reduces the potential for memory blog
the existing class or libraries that address terms of their architecture, resources, leaks, which can have a far greater
JAR files. almost anything you
can think of: sensors,
and OS capabilities. When embed-
ded systems are updated, there’s
impact on embedded systems where
applications might need to run for very
serial port commu- also a good chance that the proces- long periods in memory-constrained
27
ORACLE.COM/JAVAMAGAZINE  ///////////////////////////////////  JANUARY/FEBRUARY 2013
COMMUNITY
6
DON’T GO NATIVE environments without pH level of part of an industrial pro-
THINGS HAVE CHANGED
Some people needing to be restarted.
Concurrency support for
cess. As such, each system will have
hardware tailored to the solution being
SINCE 1995.
wrongly think that applications is also han- developed, which gives designers far

JAVA IN ACTION
by using a VM dled by the JVM. The abil-
ity to create and synchro-
greater choice than when creating a
new desktop or laptop system.
Java was originally developed in the
early 1990s to allow applications to be
rather than native nize different threads of Many embedded chip manufactur- written for the Star7 PDA, which was an
instructions, execution has been built
in from the very begin-
ers, such as Freescale and Broadcom,
create processors and systems on a
embedded device. When Java was first
launched as a general-purpose comput-
performance will ning with Java. Even if the chip (SoCs) using architectures from ing platform in 1995, the average per-
be compromised. embedded platform on companies such as ARM. Although this sonal computer had 8 MB of RAM and
which the JVM is deployed makes certain aspects of the different a processor running at less than 200

JAVA TECH
does not support multi- processors and SoCs standard, there MHz. Even today, the full Java SE run-
threading directly (some- are often small differences in terms of time requires only a minimum of 64 MB
thing that’s increasingly rare these aspects such as floating-point process- of RAM to run on Windows XP. Typical
days), it’s still possible to emulate the ing, bus architectures, and so on. Java low-end embedded systems now match
functionality through the concept of abstracts these differences away from or exceed these specifications.
green threads. the developers, making their lives sig- Java was developed from the very
Some people wrongly think that by nificantly easier. beginning to work in resource-

ABOUT US
using a virtual machine (VM) rather Reference implementations of the constrained environments, making it
than native instructions, performance Oracle Java Embedded Client are avail- ideally suited to the needs of embed-
will be compromised. With nearly 20 able for Intel x86 and MIPS as well as ded systems today. Oracle Java ME
years of development in the JVM, these ARM v5, v6, and v7 architectures run- Embedded will run in as little as 350
issues are no longer a significant fac- ning Linux (the most popular OS for KB of ROM and 130 KB of RAM (look
tor. In certain situations, having pre- embedded devices). Oracle Java SE carefully, that’s kilobytes, not mega-
cise knowledge, which is available only Embedded is available for Intel x86 bytes), growing to 1.5 MB of ROM
as the application is running, can lead and IBM Power e500v2 and e600 with 700 KB of RAM for the full, stan-
to better performance than the perfor- systems as well as ARM v5, v6, and v7 dard configuration. Oracle Java SE
mance of natively compiled code. architectures, again running Linux. Embedded is designed for more-
This gives embedded systems design- powerful systems, but still requires

5
ers plenty of choice about which plat- only 39 MB of ROM and 32 MB of RAM.
PICK AN EMBEDDED PLATFORM—
ANY EMBEDDED PLATFORM. form to use. Having to deal with lower clock
speeds also means that the Java plat-
form works well when you want to blog
Embedded systems are generally maximize the time between charges
designed to solve a specific problem, for battery-powered devices. When
whether it is how to provide in-car resources are tight, Java can still get
entertainment or how to monitor the the job done.
28
ORACLE.COM/JAVAMAGAZINE  ///////////////////////////////////  JANUARY/FEBRUARY 2013
COMMUNITY
Java Embedded: Start Developing
7
combinations with different capabilities and modems “GIVE US THE TOOLS, AND
that will provide developers one board that spans many WE WILL FINISH THE JOB.”*
different device types. Included on the motherboard are
Tori Wieldt, Java Magazine technology editor, caught up
WiFi a/b/g/n, an SD card slot, four DB9 connectors, five
with Kevin Smith of Oracle Technical Business

JAVA IN ACTION
LEDs, JTAG, USIM, GPIO, SPI, and I2C. The board even Developing code requires tools; the
Development and got the latest on Oracle Java ME better the tools, the easier the job is
runs on the included battery. It also comes with sensors
Embedded. to finish and the more quickly it gets
for temperature and light; GPS; and a 3-D accelerometer,
Java Magazine: What’s new for partners in the Java ME done. Today, time to market is just as
so developers will be able to prototype solutions for con-
embedded space? critical as functionality for a product’s
tainer management, building automation, automotive,
Smith: We announced Oracle Java ME Embedded at success.
and the next wave of cool devices on the board. We also
JavaOne San Francisco 2012. It’s pretty exciting because Tools for writing assembler and
have a Java ME Software Development Kit integrated
it represents a new Java platform that addresses the C code for embedded systems tend
with the NetBeans IDE that emulates the features of the

JAVA TECH
needs of the machine-to-machine [M2M] market and toward text editors and command-
board. We really think that this is going to accelerate time
the Internet of Things. We have been working closely line tool chains controlled by esoteric
to market for developers because they can get their hands
with Cinterion and Qualcomm on this. Oracle Java ME tools such as Make. These work, but
on the platforms as soon as they are available, rather
Embedded contains JSR 228, Information Module they severely limit the productivity
than waiting for OEM [original equipment manufacturer]
Profile—Next Generation. The Java ME team has been of developers. Java developers have
prototypes. It’s very exciting. Additional good news for
working for many years connecting people to the internet a great deal of choice of commercial
developers: these prototype boards usually cost around
with PCs, wireless handsets, tablets, and laptops, and as well as free and open source inte-
$5,000 for a single solution, and with the Orion board

ABOUT US
Oracle Java ME Embedded represents the platform that grated development environments
they can get a scalable platform for around $500.
will connect things to the internet. Depending on which (IDEs). Tools such as NetBeans and
analyst report you read, by 2020 there will be 30 to 60 Eclipse make writing code much easier
billion things connected. Now, you can use your existing and less error prone. Features such as
Java skills to program for these many devices. automatic code completion, syntax
Java Magazine: What is the Qualcomm Orion board? checking as you type, and integrated
Smith: The Orion board is Qualcomm’s developer board documentation all help to get the job
for M2M and the Internet of Things. Since the inception done more quickly and make the code
of Qualcomm’s new M2M business unit in early 2012, we more robust. As rich client platforms
have been working with Qualcomm on Oracle Java ME (RCPs), these tools are easy to extend,
Embedded support for Orion. so they can be tailored to the needs
Java Magazine: Why does this matter to a Java of specific types of application devel-
developer? opment. Development time can be
Smith: Unlike most developer boards, Orion is different in Kevin Smith of Oracle Technical Business greatly reduced by building emulators
that the system on a chip [SoC] is attached to the board Development explains what’s new for partners for the target hardware to work with a blog
via a daughter card. Qualcomm has many different SoC and Java developers in the embedded space. desktop-based IDE.

* WINSTON CHURCHILL, BBC RADIO BROADCAST, FEBRUARY 9, 1941


29
ORACLE.COM/JAVAMAGAZINE  ///////////////////////////////////  JANUARY/FEBRUARY 2013
COMMUNITY
8
program in Java. Almost BIG TALENT POOL useful information. What is
DEVELOP ON ONE MACHINE,
DEPLOY TO ANOTHER.
all universities use Java as
a teaching language for
Because the JVM the most popular platform
for developing enterprise
object-oriented program- and the class applications? Java. Using
libraries abstract

JAVA IN ACTION
Embedded systems by their very ming fundamentals, which Java in embedded devices,
nature tend not to resemble desktop
or laptop systems. Frequently they are
means that the number of
Java developers is likely to away much of in the data center for big
data processing, and on the
what is called headless, meaning that increase. the complexity desktop for presenting and
they have no display attached. This
adds extra challenges and complex-
If you want to develop
Java code, you have a huge
of developing controlling the whole sys-
tem makes architecting a
ity to software development in terms pool of programming tal- embedded system complete solution simpler,
of how to compile the code on one ent to draw on. Because the code, you don’t quicker, and cheaper.

JAVA TECH
machine and deploy it to another. JVM and the class librar- As you can see, Java
Because Java uses a VM, it doesn’t ies abstract away much of need to find people offers benefits for devel-
matter where you compile your code, the complexity of devel- who have lots of oping code for embedded
so there’s no need to set up complex
cross-compilation tool chains. Use
oping embedded system
code, you don’t need to
experience. systems. With lower cost,
more choices of platform,
your favorite Java IDE to develop the find people who have and readily available
code in comfort on your desktop, and lots of experience in this skilled developers, there’s

ABOUT US
then simply copy the class files or JAR field. For situations where nothing holding you back
files to the target device. To make more-domain-specific knowledge from helping to build the Internet of
developers’ lives even easier, most is required, there will still be a larger Things. </article>
IDEs support the concept of remote number of Java-capable developers to
debugging through a network connec- fill these positions.
tion. If the code is doing what you told Simon Ritter is a Java technology evan-
gelist at Oracle. He has worked in both

10
it to do, rather than what you wanted it
FROM DEVICE Java technology development and consul-
to do, simply use the debugging facili- TO DATA CENTER . . .
ties in your IDE to figure out what the tancy. He now focuses on the core Java
issues are. This will be a lot faster than platform and Java for client applications.
using print statements. For embedded systems to have real
value, they need to be networked,

9
not just to other embedded systems
NINE MILLION DEVELOPERS
but also to places where data can be
CAN’T BE WRONG. blog
aggregated, analyzed, and searched.
This is what data centers are good
Depending on whose survey you con- at, recording and processing huge
sult, there are up to 9 million devel- amounts of data from many different
opers in the world who know how to sources and then mining the data for
30
ORACLE.COM/JAVAMAGAZINE  ///////////////////////////////////  JANUARY/FEBRUARY 2013

Вам также может понравиться