The Java Magzine
The Java Magzine
The Java Magzine
BUILD TODAY?
ORACLE.COM/JAVAMAGAZINE
05
2014 DUKES
CHOICE
AWARDS
11
THE MAKER
MOVEMENT
EVOLVES
16
IOT DEVELOPER
CHALLENGE
WINNERS
11
2014 DUKES
CHOICE
AWARDS
THE MAKER
MOVEMENT
EVOLVES
16
IOT DEVELOPER
CHALLENGE
25
JAVA TECH
32
New to Java
43
55
Location-Based Software
Using JavaFX
Java Architect
36
48
Java Architect
Enterprise Java
ABOUT US
COMMUNITY
03
From the Editor
16
Java Nation
JAVA TECH
COMMUNITY
05
JAVA IN ACTION
//table of contents /
Rich Client
60
Embedded
66
Fix This
blog
01
RESOURCES
Oracle Products
+1.800.367.8674 (US/Canada)
Oracle Services
+1.888.283.0591 (US)
Oracle Press Books
oraclepressbooks.com
ARTICLE SUBMISSION
If you are interested in submitting an article, please e-mail the editors.
COMMUNITY
JAVA IN ACTION
ADVERTISING SALES
President, Sprocket Media
Kyle Walkenhorst+1.323.340.8585
Western and Central US, LAD, and
Canada, Sprocket Media
Tom Cometa+1.510.339.2403
Eastern US and EMEA/APAC,
Sprocket Media
Mark Makinney+1.805.709.4745
Advertising Sales Assistant
Cindy Elhaj +1.626.396.9400 x 201
Mailing-List Rentals
Contact your sales representative.
REGISTER NOW
JAVA TECH
DESIGN
Senior Creative Director
Francisco G Delgadillo
Senior Design Director
Suemi Lam
Design Director
Richard Merchn
Contributing Designers
Jaime Ferrand, Diane Murray,
Arianna Pucherelli
Production Designers
Sheila Brennan, Kathy Cygnarowicz
PUBLISHING
Publisher
Jennifer Hamilton+1.650.506.3794
Associate Publisher and Audience
Development Director
Karin Kinnear+1.650.506.1985
ABOUT US
EDITORIAL
Editor in Chief
Caroline Kvitka
Community Editor
Yolande Poirier
Java in Action Editor
Michelle Kovac
Technology Editor
Tori Wieldt
Contributing Writer
Kevin Farnham
Contributing Editors
Claire Breen, Blair Campbell,
Kay Keppler, Karen Perkins
oracle.com/javaone
SUBSCRIPTION INFORMATION
Subscriptions are complimentary for qualified individuals who complete the
subscription form.
MAGAZINE CUSTOMER SERVICE
[email protected] Phone +1.847.763.9635
PRIVACY
Oracle Publishing allows sharing of its mailing list with selected third parties. If you prefer
that your mailing address or e-mail address not be included in this program, contact
Customer Service.
Copyright 2014, Oracle and/or its affiliates. All Rights Reserved. No part of this publication may be reprinted or otherwise
reproduced without permission from the editors. JAVA MAGAZINE IS PROVIDED ON AN AS IS BASIS. ORACLE EXPRESSLY
DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY
DAMAGES OF ANY KIND ARISING FROM YOUR USE OF OR RELIANCE ON ANY INFORMATION PROVIDED HEREIN. The
information is intended to outline our general product direction. It is intended for information purposes only, and may not be
incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied
upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracles
products remains at the sole discretion of Oracle. Oracle and Java are registered trademarks of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
blog
Silver Sponsor
Bronze Sponsors
Diamond Sponsor
02
*Save $400 over onsite registration. Visit oracle.com/javaone/register for early bird registration dates and details.
Copyright 2014, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered
trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
ecause we get to build stuff. That was my nine-year-old sons response to my question about why
aviation camp at our local airport was his favorite camp this summer. While kids seem to always be building
stufffrom sand castles to LEGOsas adults we have to try harder to keep that desire to build alive. Why build
when you can buy? Luckily, the reasons to build, create, and do it yourself are endless. In this issue, we celebrate
the spirit of making and the people who are creating new and innovative technologies and services.
In our interview with Dale Dougherty, Make: magazine founder and Maker Faire cocreator, we explore whats
behind the growing Maker Movement and how it relates to software development. Were on the cusp of a new
creative industry that is taking product design and the web and beginning to link them, he says. One of the
great starting points for developers is a standardized board such as the Arduino.
We also recognize the winners of the 2014 Dukes Choice Awards, which honor compelling and innovative uses
of Java technology. These winning makers help ensure safer travel, feed hungry refugees, improve crop yields,
provide cool technology, and aim to end a decade-long debate in the Java community.
Were also excited to recognize the winners of the first-ever IoT Developer
//send us your feedback /
Challenge, sponsored by Oracle Technology Network and Oracle Academy. Winners
Well review all
used embedded Java with computer boards, such as the Raspberry Pi, and other
suggestions for future
devices and IoT technologies to showcase innovations in domotics, robotics, office
improvements.
design, authentication, and rating systems.
Depending on volume,
Congratulations to all of the winners, who show us that the spirit of making is alive
some messages might
not get a direct reply.
and well. Inspired? Get out there and build something.
BIO
Introducing the
Java Magazine Career
Opportunities section
the ultimate technology
recruitment resource.
Place your advertisement
and gain immediate access
to our audience of top IT
professionals worldwide
including: corporate and
independent developers, IT
managers, architects and
product managers.
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
blog
03
JAVA IN ACTION
COMMUNITY
2014 DUKES
CHOICE AWARDS
JAVA TECH
ABOUT US
Apache DeltaSpike,
Apache Software
Foundation
Apache TomEE,
Apache Software
Foundation
Autonomous Vehicle
Test System, Perrone
Robotics for the
Insurance Institute for
Highway Safety
DukeScript, Eppleton
IT Consulting and the
NetBeans project
IBFieldbook,
International
Maize and Wheat
Improvement Center
JavaFXPorts, LodgON
JCertif International
libGDX
PiDome
Project JEDI, Java
Education &
Development Initiative
blog
05
Chief Researcher,
Air Traffic Controller
Selection System
COMMUNITY
JAVA IN ACTION
SAFETY FIRST
JAVA TECH
2014 DUKES
CHOICE AWARDS
ABOUT US
blog
06
FIGHTING HUNGER
2014 DUKES
CHOICE AWARDS
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
blog
07
COMMUNITY
JAVA IN ACTION
2014 DUKES
CHOICE AWARDS
Leader, PiDome
ABOUT US
STRONGER AS ONE
JAVA TECH
COOL TECH
blog
08
COMMUNITY
JAVA IN ACTION
JAVA TECH
How fitting that in its 12th year the Dukes Choice Awards has 12 winners,
thanks to the first-ever three-way tie in the voting for the coveted Community
Choice Award.
The first of the trio is Project JEDI, for the Java Education & Development
Initiative. This community-driven organization provides free courseware and
training on Java and open source technologies to colleges and universities
around the world. Originally started in the Philippines, Project JEDI now partners with Java user groups (JUGs), academic institutions, government agencies, and businesses around the world to translate and provide the course
materials in other languages.
The second winner is the Apache Software Foundations Apache
DeltaSpike developer toolbox for Java Contexts and Dependency Injection
(CDI) for the Java EE 6 platform. Apache DeltaSpike allows developers to
introduce and test new features in Java EE before they are standardized, such
as transaction support for CDI beans, which wasnt available until Java EE 7.
The third winner, JavaFXPorts, from LodgON, is also an open source toolkit. For the first time, it makes graphically rich Java and JavaFX available to
mobile and tablet devices running iOS and Android operating systems.
ABOUT US
2014 DUKES
CHOICE AWARDS
blog
09
COMMUNITY
JAVA IN ACTION
JAVA TECH
2014 DUKES
CHOICE AWARDS
ABOUT US
SETTLING A DEBATE
blog
10
COMMUNITY
JAVA IN ACTION
JAVA TECH
THE
MAKER
MOVEMENT
EVOLVES
he Maker Movement, a fast-growing do-ityourself (DIY) culture focused on such innovative pursuits as robotics, electronics, and 3-D
printing, along with traditional activities such
as metalworking, woodworking, and arts and crafts, has
reached critical mass. At the first-ever White House Maker
Faire, held on June 17, 2014, President Barack Obama
called on people across the country to join us in sparking
creativity and encouraging invention in their communities. He proclaimed June 18, 2014, a day of making and
stated, Thanks to the democratization of technology, it
is easier than ever for inventors to create just about anything. Across our nation, entrepreneurs, students, and
families are getting involved in the Maker Movement.
The convergence of the growing Internet of Things (IoT),
big data, machine-to-machine technology, and cloud
computing, along with enhanced embedded applications,
has made it clear that the hardware innovation fostered
PHOTOGRAPH BY ORACLE
ABOUT US
BY TIMOTHY BENEKE
blog
11
COMMUNITY
JAVA IN ACTION
JAVA TECH
Java Magazine: Whats been happening
lately in the Maker Movement?
Dougherty: For starters, we had a
White House Maker Faire recently,
which tells us that the Maker Movement
is moving from the margins to the
mainstream. Im quite happy about
the impact it can have in areas such as
manufacturing, innovation, and especially educationand even in civic and
community areas as well. The Maker
Movement is a widely distributed social
network that anyone can join. You identify yourself as a maker and youre in.
We are trying to reach people who
dont identify as makers and show them
ABOUT US
blog
12
Left: Dougherty at Maker Faire Kansas City. Right: Kids learn and play at Maker Faire Bay Area.
easy to use. And the time it takes to make
things is collapsing. So you might be scratching your head with a good idea and feel like,
well, I dont know how to get this done. Making
initially has a DIY nature, but as people get
involved they meet others and there is more
collaborative production.
I met a man recently who was paralyzed from
a diving accident and is confined to a wheelchair that has a vertical pole like a joystick that
is used for control. He has a paralyzed hand and
cant wrap his hand around the pole to use it
effectivelyin fact, he was just resting his hand
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
blog
13
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
blog
14
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
blog
15
JAVA IN ACTION
COMMUNITY
//java nation /
IoT
DEVELOPER
CHALLENGE
ABOUT US
JAVA TECH
blog
16
JAVA TECH
Warateks Nigel Daniels talks about
security solutions for the JVM.
ABOUT US
JVM
LANGUAGE
SUMMIT
JAVA IN ACTION
COMMUNITY
//java nation /
blog
17
Its standing-room-only
at a Rome JUG meeting.
When in Rome . . . attend a Java User
Group (JUG) Roma meeting. Rome JUG
was founded in December 2005 by Mara
Marzocchi and Ugo Landini; the current
leadership includes Vitalij Zadneprovskij.
Rome JUG initiated the annual Java Day in
Rome, and its success has been expanded
by Marzocchi, a cofounder of the startup
Codemotion, which organizes conferences
and workshops in Germany, Israel, Italy,
and Spain.
The group has more than 950 members
on its mailing list, says Zadneprovskij. The
group meets every month or two, with an
average of 15 attendees. Meetings are held
OTN Virtual
Technology
Summit
Oracle Technology Network held its first
Virtual Technology Summit in July 2014.
The free event included tracks on database, middleware, and systems andof
courseJava. In the Java track, titled Big
Trends and Technologies, attendees
learned how Java lets you mine big data;
build robust apps with HTML5, JavaScript,
and Java EE; and expand into the Internet
of Things (IoT). Java sessions and presenters included Efficient Architectures for
Creating MapReduce Pipelines, by Fabiane
Nardon, Java Champion and big data
expert; JavaScript/HTML5 Rich Clients
Using Java EE 7, by Reza Rahman, Java
evangelist and Java EE expert; and How
to Become an Embedded Developer, by
Angela Caicedo, Java evangelist and Java
embedded expert. The summit content is
now available on demand.
JAVA TECH
ABOUT US
JAVA IN ACTION
COMMUNITY
//java nation /
blog
18
ORACLE.COM/JAVAMAGAZINE //////////////////////////////// SEPTEMBER/OCTOBER 2014
COMMUNITY
JAVA IN ACTION
JAVA TECH
INTRODUCING ROBOBURGH
ABOUT US
//java nation /
blog
19
OSCON:
The Java
Community Process
(JCP) celebrated its
15th anniversary
with a gathering
at the Computer
History Museum
in Mountain View,
California, on June 18, 2014. The event, cohosted
by the JCP program office and the Silicon Valley
Java User Group, was a chance for members of the
Java community and some of the people instrumental in the JCPs success to network and check
out the cool museum exhibits.
For 15 years the JCP has been working with
corporations, individuals, nonprofits, and Java user
groups to advance and improve the Java platform,
said JCP Chair Patrick Curran. Every few years we
like to get together and say thank you, because
Java would be nothing without you.
He recognized many of the luminaries who had
played a part in the JCP over the years, including
James Gosling, George Paolini, Rob Gingell, Onno
Kluyt, Bill Shannon, and Vineet Gupta, and then
asked everyone to raise a glass to the JCP. Later,
Duke shook hands and posed with attendees.
Watch Stephen Chins interviews with Gosling,
Gingell, Van Riper and Kevin Nilson, and others.
JAVA TECH
JCP Celebrates
15 Years
ABOUT US
JAVA IN ACTION
COMMUNITY
//java nation /
blog
20
Clockwise
from top: a
Devoxx UK
expert panel,
Fearless
Change
presenters
Linda van der
Pal (left) and
Rgina ten
Bruggencate,
a red-hatted
attendee with
a message
PHOTOGRAPHS BY ORACLE
JAVA TECH
ABOUT US
DEVOXX UK:
JAVA IN ACTION
COMMUNITY
//java nation /
blog
21
The Next
Big Thing?
Do you have an idea for the
next killer app or a practical business service? You
could win a trip to GeeCON
in Krakw, Poland, or present
your ideas at the NextGen conference in London, England.
Orange Labs is hosting the
Business Intelligence hackathon API (BihAPI) and is
opening its labs for developers
to write cool, innovative applications that extract core network features such as device
location, in-application
charging, messaging, and Web
Real-Time Communications.
The Polish cities of Warsaw,
Gdask, and Pozna will
expose government records
such as bus and tram timetables, park and ride locations, maps, and much
more. Registration opens
October 2, and the hackathon
runs through November 2014.
Fabiane Bizinella
Nardon is a computer scientist, innovator, entrepreneur,
and impossible
projects expert. She
won a Dukes Choice
Award in 2005 for
her development
work on Brazils
National Health
System and became
a Java Champion in
February 2006.
Java Magazine:
Where did you
grow up?
Nardon: I grew up in
a small town in the
I can. Usually I do
long cycling rides
or Pilates, walk
through the city,
meet with friends,
and sometimes
enjoy just staying
home with a good
book or movie.
Java Magazine: What
side effects of your
career do you enjoy
the most?
Nardon: A career in
computer science
is amazing. There
are plenty of jobs
(at least where I
live), and you have
the power to create
something new and
really change lives.
Java Magazine:
Has being a Java
Champion changed
anything for you
with respect to your
daily life?
Nardon: I feel that
Im better connected, and that
can be really helpful in your career.
JAVA TECH
FABIANE NARDON
ABOUT US
JAVA IN ACTION
COMMUNITY
//java nation /
blog
22
ORACLE.COM/JAVAMAGAZINE //////////////////////////////// SEPTEMBER/OCTOBER 2014
JAX London
OCTOBER 1315
LONDON, ENGLAND
EVENTS
Code.talks 2014
ANTWERP, BELGIUM
OCTOBER 910
HAMBURG, GERMANY
OCTOBER 1112
LOS ALTOS HILLS, CALIFORNIA
At this free community event, developers learn from fellow developers about software development,
software branding, and legal issues
around software.
COMMUNITY
JAVA IN ACTION
OCTOBER 1314
KRAKOW, POLAND
JAVA TECH
JDD 2014
ABOUT US
//java nation /
OCTOBER 2324
PRAGUE, CZECH REPUBLIC
W-JAX
NOVEMBER 37
MUNICH, GERMANY
blog
23
COMMUNITY
//java nation /
JAVA BOOKS
NOVEMBER 46
CASABLANCA, MOROCCO
J-Fall
NOVEMBER 5
NIJKERK, THE NETHERLANDS
By Deepak Vohra
Cengage Learning, June 2014
JAVA PERFORMANCE:
THE DEFINITIVE GUIDE
By Scott Oaks
OReilly Media, April 2014
ABOUT US
JMaghreb
JAVA TECH
JAVA IN ACTION
EVENTS
blog
24
ORACLE.COM/JAVAMAGAZINE //////////////////////////////// SEPTEMBER/OCTOBER 2014
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
blog
25
ORACLE.COM/JAVAMAGAZINE //////////////////////////////// SEPTEMBER/OCTOBER 2014
CLOUD ECOSYSTEM
public talks, broad research cooperation, and key patents. Shelby has served
on the technical advisory board and
is currently on the board of directors
at the Internet Protocol Smart Object
(IPSO) Alliance. He was elected to the
Java Community Process (JCP) Executive
Committee in 2014.
Java Magazine: Give us a quick overview
of the interplay between innovation
and standards in the IoT arena.
Shelby: If we look back to the development of internet protocols, it was
all about facilitating innovation. That
should be the goal. Standardized methodologies were created for moving packets between sites, which led to the creation of HTTP and the web. The ability
to create web pages, host them on any
web server, and disseminate the data
COMMUNITY
ABOUT US
JAVA TECH
JAVA IN ACTION
blog
26
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
blog
27
COMMUNITY
JAVA TECH
test harness and debugging by looking at signals on a wire with an oscilloscope. Thats still important work; we
need people to create those underlying
technologies. But now we need products that are exciting and sexy.
The Maker Movement is creating this kind of energy, facilitating
inventors in 3-D printing; robotics;
Computer Numerical Control [CNC];
and even woodworking, metal working, and traditional arts and crafts. In
response to this movement, developers
are producing tools that have broader
applicability. The mbed platform is an
example of this evolution. The Arduino
single-board microcontroller is another
example. It has made the experience
of configuring an embedded device
very simple. Weve just launched a new
ARM-based Arduino device.
The Maker Movement will motivate
more and more technology to service these widely diverse activities.
Professional developers, product manufacturers, startups, and hobbyists will
all be in the game.
Java Magazine: What are some of the
standards evolving in this space? And
how does the IPSO Alliance promote
innovation?
ABOUT US
JAVA IN ACTION
28
COMMUNITY
JAVA IN ACTION
JAVA TECH
Shelby presents
to colleagues in a
meeting room at
ARMs San Jose,
California, offices.
ABOUT US
blog
29
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
Steve Meloan is a former C/UNIX software developer who has covered the web
and the internet for such publications as
Wired, Rolling Stone, Playboy, SF Weekly,
and the San Francisco Examiner. He recently published a science-adventure
novel, The Shroud, and regularly contributes to The Huffington Post.
LEARN MORE
blog
30
PHOTOGRAPH BY
JOHN BLYTHE
JAVA TECH
BIO
Figure 1
track the motion of human
bodies in three dimensions.
By connecting Kinect to
Greenfoot, we can create
games that we can control
with our bodies: No hitting of
keys and no mouse clicks
just jumping up and down
and waving your arms in
the air.
ABOUT US
MICHAEL KLLING
COMMUNITY
Part 1
JAVA IN ACTION
//new to java /
blog
32
JAVA IN ACTION
JAVA TECH
COMMUNITY
//new to java /
Figure 2
Figure 3
getTrackedUsers() method for this
purpose.
Once we have a UserData object,
we can work individually with each
user that is being tracked. Some
of the methods available for a user
are methods to draw a stick figure
of the user and to receive information about individual joints, such
as those for the hands, knees, feet,
and head. Kinect tracks the 15
joints shown in Figure 4.
You can see all the available methods by opening the
UserData class in Greenfoot,
and then switching the editor
from Source Code view to the
Documentation view.
When we use a method, such
as getJoint, to receive information about a joint, we will receive
an object of class Joint. We can
ABOUT US
blog
Figure 4
33
By connecting
Microsoft Kinect
to Greenfoot,
we can create
games that we
can control with
our bodies: No
hitting of keys and
no mouse clicks
just jumping up
and down and
waving your arms
in the air.
LISTING 4
COMMUNITY
LISTING 3
JAVA IN ACTION
then use that object to get moreon his or her own layer.
detailed information, such as the
The Canvas class. We will do all
x-coordinate and y-coordinate of
our work in the Canvas class. This is
the joint on the screen. (Refer to
where all the fun is.
Figure 3.) The Joint class also conLets have a quick look at the contains constants for identifying each
structor code shown in Listing 1.
individual joint.
We can see that the UserData
The setup. Our own scenario gets
object for the user associated with
initialized in the PaintWorld class.
this canvas is received and stored
We will not discuss the code in
for later use. Then a transpardetail here; you can read the code
ent Greenfoot image on which to
yourself if you are curious, or you
paint is created. Lastly, a random
can ignore it for now. But here is a
color is selected from an array of
summary of its purpose.
predefined colors (defined further
The PaintWorld object, in every
up in the class), and it is set as the
Greenfoot act cycle, looks for all
color for future painting operations.
tracked users (that is,
The act method.
all users who are in the
Although the construcGET PHYSICAL
view of the Kinect camtor is executed only
era) and creates a Canvas
once, the Greenfoot act
object for every user
method is executed
it detects.
repeatedly as long as the
A Canvas is a
scenario is running. It,
Greenfoot object that
too, is fairly simple (see
has a transparent image
Listing 2).
the size of the entire
In this method, we
Greenfoot world, and it
use the user object to
is linked to one tracked
get information about
user. Since it is entirely
the right hand by using
transparent, it will inithe user.getJoint(Joint
tially be invisible. So if
.RIGHT_HAND) method
Kinect currently sees,
call. This will give us an
for instance, two users,
object of type Joint.
there will be two Canvas
We can then use the
objects in the Greenfoot
joints getX() and getY()
world acting as (invismethods to determine
ible) painting layers,
the right hands position
and each user paints
on the screen and then
LISTING 2
JAVA TECH
LISTING 1
ABOUT US
//new to java /
getImage().clear();
blog
34
Conclusion
COMMUNITY
3 Billion
JAVA IN ACTION
if (user.getJoint(Joint.RIGHT_FOOT).getY() <
user.getJoint(Joint.LEFT_KNEE).getY())
{
getImage().setColor(
colors[Greenfoot.getRandomNumber(colors.length)]);
}
ABOUT US
LISTING 5
JAVA TECH
//new to java /
#1 Development Platform
LEARN MORE
blog
35
Learn how to examine JIT logs to see what the JIT compiler is doing (and why).
O
BEN EVANS AND
CHRIS NEWLAND
BIO
JITWatch is
a graphical
visualization
and analysis
tool for understanding the
JIT compilation
of applications.
Its open source
and is being
developed as
part of the Adopt
OpenJDK project.
compilation of applications.
Its open source software and
is being developed as part of
the Adopt OpenJDK project.
The source code for JITWatch
is available from GitHub.
JITWatch needs a JIT
compilation log file in order
to work. As mentioned in
the previous article, there
are two different log formats that Java HotSpot
VM can produce. JITWatch
requires the more verbose,
XML-based log that is produced by the LogCompilation
switch. JITWatch requires
the TraceClassLoading switch
as well, so the full set of
switches needed to produce
a suitable log for JITWatch is
the following:
-XX:+UnlockDiagnosticVM
Options
-XX:+LogCompilation
-XX:+TraceClassLoading
COMMUNITY
JAVA IN ACTION
JAVA TECH
Part 2
ABOUT US
//java architect /
blog
36
COMMUNITY
//java architect /
Figure 1
directory is $JAVA_HOME/jre/lib/
server/.
Note: For Mac users, try the bsdlibhsdis-i386.dylib file and rename it
to hsdis-amd64.dylib before copying
it to the Java library directory.
The instructions here describe
how to build your own HSDIS plugin from scratch.
Many Java developers have only
limited experience working with
assembly code, so the prospect
of using HSDIS seems daunting.
However, with time and some
diligence, a working knowledge of
assembly code is well within the
grasp of the majority of developers. Here are some pointers to help
ABOUT US
JAVA TECH
JAVA IN ACTION
blog
37
Done
COMMUNITY
$ ./makeDemoLogFile.sh
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
VM Switches -XX:+UnlockDiagnosticVMOptions
-XX:+TraceClassLoading -XX:+LogCompilation
-XX:-TieredCompilation -XX:+PrintAssembly -XX:-UseCompressedOops
Building example HotSpot log
Java HotSpot(TM) 64-Bit Server VM warning: PrintAssembly is
enabled; turning on DebugNonSafepoints to gain additional output
JAVA IN ACTION
LISTING 1
JAVA TECH
//java architect /
ABOUT US
Figure 2
blog
Figure 3
38
JAVA IN ACTION
JAVA TECH
Figure 4
ABOUT US
COMMUNITY
//java architect /
Figure 5
blog
Figure 6
39
Inlining
COMMUNITY
ABOUT US
JAVA IN ACTION
LISTING 2
JAVA TECH
//java architect /
blog
Figure 7
ORACLE.COM/JAVAMAGAZINE //////////////////////////////// SEPTEMBER/OCTOBER 2014
40
Suggestion Tool
COMMUNITY
JAVA IN ACTION
ABOUT US
JAVA TECH
//java architect /
blog
Figure 8
ORACLE.COM/JAVAMAGAZINE //////////////////////////////// SEPTEMBER/OCTOBER 2014
41
ABOUT US
JAVA TECH
JAVA IN ACTION
COMMUNITY
//java architect /
Figure 9
To finish, lets briefly discuss
another JITWatch feature: the suggestion tool. For some developers,
this will be the jewel in the crown,
because it can describe the reason
why a certain JIT compilation decision was made (and why various
JIT compilation techniques failed).
Figure 9 shows an example.
In Figure 9, we can see some
examples of a couple of different
failure types. In one case, branches
within methods could not be reliably predicted, and in the other,
the methods were too big to be
Conclusion
blog
LEARN MORE
GitHub page for JITWatch
42
BIO
et me guess a couple of
things about you. First, you
are fluent in Java. Second, you
have a smartphone, tablet, or
both within reach. Am I right?
Well, with the explosion of
mobile device popularity, plus
the fact that you are reading
Java Magazine, these were not
really tough guesses to make.
What might be a bit
tougher is answering this
COMMUNITY
JAVA IN ACTION
SHAY SHMELTZER
Build mobile apps with Oracle Mobile Application Framework, a Java-based hybrid mobile platform.
JAVA TECH
ABOUT US
//java architect /
blog
43
Powerful Development
Framework
COMMUNITY
JAVA IN ACTION
ABOUT US
JAVA TECH
//java architect /
blog
Figure 1
44
JAVA IN ACTION
JAVA TECH
Figure 2
and drop will create the expression language that will connect a UI
component to a datasource.
ABOUT US
and add them to the list of components you can use later on.
Past experience with spaghetti
codebased coding (servlets,
JavaServer Pages) taught us about
the importance of proper functional
layer separation when building and
maintaining apps, and in Oracle
Mobile Application Framework,
this is implemented with the MVC
design pattern.
For the controller layer, Oracle
Mobile Application Framework
provides a process flow engine that
allows you to define navigation
between pages in your applications and also include method calls,
decision points, and other flows in
a flow. Code in the controller layer is
written in simple Java classes that
are similar in concept to managed
beans in JSF.
Managed beans can also contain
data that will be exposed in the UI
layer. Oracle Mobile Application
Framework provides various scopes
for beans to better handle memory
allocation. In addition, data can be
incorporated from a remote server
through both REST (JSON or XML)
and SOAP services.
Oracle Mobile Application
Framework uses a declarative databinding layer to reduce the amount
of code you need to manually write
to hook up your UI components to
the data and business services. At
development time, a simple drag
COMMUNITY
//java architect /
blog
45
COMMUNITY
//java architect /
JAVA IN ACTION
ABOUT US
JAVA TECH
IDE Integration
Figure 3
Want to get an impression of the
overall development experience?
Watch these 10-minute demos
showing end-to-end development
with Oracle Mobile Application
Framework in Eclipse and Oracle
JDeveloper.
Getting Started
Conclusion
LEARN MORE
Oracle Mobile Application
Framework website
blog
46
CAREER OPPORTUNITIES
MANAGE YOUR CAREER PATH AT DICE.COM
Java Jobs
at your Fingertips
Dice is the leading career site for
information technology and
engineering professionals.
BIO
In a nutshell, Oracle
WebLogic Server is a scalable
Java EE application server that
offers a full implementation
of the Java EE 6.0 specification, which is a standard set
ORACLE.COM/JAVAMAGAZINE //////////////////////////////// SEPTEMBER/OCTOBER 2014
COMMUNITY
JAVA IN ACTION
MICHAEL HTTERMANN
Make your applications more robust, secure, highly available, and scalable.
JAVA TECH
ABOUT US
//enterprise java /
blog
48
JAVA IN ACTION
JAVA TECH
ABOUT US
COMMUNITY
//enterprise java /
Figure 1
using Oracle WebLogic Server
version 12.1.3.0.0.
First, download Oracle WebLogic
Server. Also download a recent version of JDK 8 and NetBeans IDE 8.
After you install Oracle WebLogic
Server locally, its administration
console is reachable at http://
localhost:7001/console, as shown
in Figure 1.
1 ORACLE WEBLOGIC SERVER 12c SUPPORTS JAVA EE 6. FOR THE MORE RECENT EDITION FOR JAVA EE 7, SEE http://docs.oracle.com/javaee/7/tutorial/doc.
blog
49
Figure 3
ABOUT US
Figure 2
JAVA TECH
JAVA IN ACTION
COMMUNITY
//enterprise java /
Figure 4
COMPONENT
DESCRIPTION
ADMINSERVER
A DOMAIN INCLUDES ONE ORACLE WEBLOGIC SERVER INSTANCE THAT IS CONFIGURED AS THE
ADMINSERVER. ALL CHANGES TO THE CONFIGURATION AND DEPLOYMENT OF APPLICATIONS
ARE DONE THROUGH THE ADMINSERVER.
MANAGED SERVERS
ALL OTHER ORACLE WEBLOGIC SERVER INSTANCES IN A DOMAIN ARE CALLED MANAGED
SERVERS. MANAGED SERVERS HOST APPLICATION COMPONENTS AND RESOURCES, WHICH
ARE ALSO DEPLOYED AND MANAGED AS PART OF THE DOMAIN.
CLUSTERS
A DOMAIN CAN ALSO INCLUDE ORACLE WEBLOGIC SERVER CLUSTERS, WHICH ARE GROUPS OF
MANAGED SERVER INSTANCES THAT WORK TOGETHER TO PROVIDE SCALABILITY AND HIGH
AVAILABILITY FOR APPLICATIONS. CLUSTERS CAN IMPROVE PERFORMANCE AND PROVIDE
FAILOVER WHEN A SERVER INSTANCE BECOMES UNAVAILABLE.
blog
Table 2
shown in Table 2.
In production environments,
it is highly recommended that
50
JAVA IN ACTION
Figure 5
ter, application processing can
continue when a server instance
fails. You cluster application
components by deploying them
on multiple server instances
in the clusterso, if a server
instance on which a component
is running fails, another server
instance on which that component is deployed can continue
application processing.
Key clustering capabilities that
enable scalability and HA include
the following:
Application failover. Failover
means that when an application
component doing a particular
task becomes unavailable for
any reason, a copy of the failed
object finishes the task.
Migration. Oracle WebLogic
Server supports automatic and
manual migration of a clus-
JAVA TECH
ABOUT US
COMMUNITY
//enterprise java /
blog
Achieving Persistence
51
publish-subscribe model
Manage pooled connections for
high performance and scalability; Figure 7 shows weighted or
round-robin load balancing
Another great capability of Active
GridLink for Oracle RAC is its XA
affinity, a feature that ensures that
COMMUNITY
JAVA TECH
Figure 6
ABOUT US
JAVA IN ACTION
//enterprise java /
blog
Figure 7
52
jdbc:oracle:thin:@
(DESCRIPTION=(ADDRESS_
LIST=(ADDRESS=(PROTOCOL=TCP)
(HOST=left)(PORT=1234))
(ADDRESS=(PROTOCOL=TCP)
(HOST=right)(PORT=1234))
(ADDRESS=(PROTOCOL=TCP)
(HOST=center)(PORT=1234)))
(CONNECT_DATA=(SERVICE_
NAME=myService)))
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
//enterprise java /
blog
53
>java weblogic.WLST
Initializing WebLogic Scripting Tool (WLST) ...
Welcome to WebLogic Server Administration Scripting Shell
Type help() for help on available commands
wls:/offline>help('connect')
wls:/offline>connect('admin', 'pw', 't3://localhost:7001')
Connecting to t3://localhost:7001 with userid admin ...
Successfully connected to Admin Server "myserver" that belongs
to domain "mydomain".
wls:/mydomain/serverConfig>
wls:/mydomain/serverConfig>threadDump()
JAVA IN ACTION
LISTING 2
JAVA TECH
LISTING 1
COMMUNITY
//enterprise java /
LEARN MORE
Oracle WebLogic Server
documentation
ABOUT US
blog
54
COMMUNITY
//rich client /
PHOTOGRAPH BY
TON HENDRIKS
he concept of location is
becoming more and more
important in a number of
services. Combining content
with location-based information enriches the content.
With a growing number of
location-aware devices, there
is an increasing amount of
data that can be associated
with a location.
The JavaFX platform provides a number of features
that allow Java developers to
visualize location-based data
in an accurate, fancy, and
performant way. In this article, well explore some of the
benefits the JavaFX platform
provides when you are developing visualization software
for location-based services.
The OpenMapFX project is
an open source, communitydriven project that provides
a number of location-based
services and tools. The core
Rendering Tiles
Geo-location information is
often rendered using tiles.
A tile is a small image (typically 256 by 256 pixels) containing a segment of the
world map at a given zoom
level. A number of map
providers (such as Google
Maps, OpenStreetMap, and
MapQuest) provide their
map data using an HTTP
service that takes a simple
parameterized request and
returns the requested tile as
an image.
In this article, we see
by pointing a browser to
http://tile.openstreetmap
.org/0/0/0.png.
This URL, and all the URLs
for obtaining tiles, is constructed as follows: http://
base-url/z/i/j.png, where
base-url is the URL for the
specific tile provider, and z,
i, and j are the three parameters described earlier.
Each incremental zoom
level contains four times the
number of tiles as the previous zoom level. For each tile
JAVA TECH
BIO
ABOUT US
JOHAN VOS
JAVA IN ACTION
Location-Based Software
Using JavaFX
blog
Figure 1
55
@Override
public void start(Stage primaryStage) {
Image image = new Image(
"http://tile.openstreetmap.org/0/0/0.png");
ImageView imageView = new ImageView(image);
StackPane root = new StackPane();
root.getChildren().add(imageView);
Scene scene = new Scene(root,300, 300);
primaryStage.setTitle("TileMap 1");
primaryStage.setScene(scene);
primaryStage.show();
}
Figure 2
an Image object and pass the URL
to the constructor. Next, we wrap
the Image object in an ImageView
instance, which can be rendered
in the scene. The code in Listing 1
shows how to do this.
The result of running the code
shown in Listing 1 is a 256 by 256
image that shows a static world
map (see Figure 3).
COMMUNITY
LISTING 3
JAVA IN ACTION
LISTING 2
JAVA TECH
LISTING 1
ABOUT US
//rich client /
blog
56
LISTING 4
LISTING 7
JAVA IN ACTION
the node (the point with coordinates 0,0). This causes the scaling
to be centered around this origin,
rather than in the center of the
node. As a consequence, the topleft corner of the node will always
be at the same position, which is
important for further calculations.
When the scaleProperty of the
map changes, we have to change
the value of the Scale transformation. This is done by adding an
InvalidationListener to the scale
Property of the map, as shown in
Listing 6. The calculatePosition
method shown in Listing 7 will
apply the correct scale factor to the
Scale instance.
Setting the x and y property of
the Scale instance will cause the
MapTile node to be scaled up or
down. When the scaleFactor is
equal to the tileZoom, the scale
value (sv) will be 1 and no stretching
or shrinking will be done.
JAVA TECH
LISTING 6
ABOUT US
LISTING 5
COMMUNITY
//rich client /
blog
57
Determining Which
Tiles Should Be
Created
Combining content
with location-based
information enriches
the content. With a
growing number
of locationaware devices,
there is an increasing
amount of data that
can be associated
with a location.
LISTING 11
LISTING 12
We now try to detect the absolute lowest i index for a tile that
would at least partially fit on a
screen. With a little mathemat-
COMMUNITY
LISTING 10
JAVA IN ACTION
LISTING 9
JAVA TECH
LISTING 8
ABOUT US
//rich client /
blog
58
COMMUNITY
//rich client /
JAVA IN ACTION
ABOUT US
JAVA TECH
Possible Improvements
Figure 4
Conclusion
Property binding
Lambda expressions
Transformations (for example,
Scale)
Ability to specify all coordinates
relative to their parents (thanks
to the scene graph concepts)
blog
LEARN MORE
OpenMapFX project
OpenStreetMap
59
COMMUNITY
//embedded /
S
KAI KREUZER AND
THOMAS EICHSTDTENGELEN
BIO
PHOTOGRAPHS BY
TON HENDRIKS
A smart home
cannot be built
with a single
system or
technology,
especially if you
want to avoid
vendor lock-in. So
the only solution
is to integrate
different systems
and devices to
make them work
together.
Integration Through
openHAB
ABOUT US
Leverage openHAB and the huge Java ecosystem to create a truly smart home.
JAVA TECH
JAVA IN ACTION
blog
60
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
//embedded /
blog
61
###################################################
#######
General configurations
#######
###################################################
security:option=ON
################### HTTP Binding ###################
# configuration of the first cache item
http:weather.url
http://weather.yahooapis.com/forecastrss?w=2487956&u=f
http:weather.updateInterval=60000
################# Philips Hue Binding #################
hue:ip=192.168.0.42
hue:secret=myPersonalSecret
COMMUNITY
ABOUT US
LISTING 2
JAVA IN ACTION
LISTING 1
JAVA TECH
//embedded /
blog
62
Figure 2
COMMUNITY
LISTING 5
JAVA IN ACTION
LISTING 4
JAVA TECH
LISTING 3
ABOUT US
//embedded /
blog
63
JAVA IN ACTION
Figure 3
my.openHAB
JAVA TECH
ABOUT US
COMMUNITY
//embedded /
Figure 4
blog
Figure 5
64
Smart homes
currently involve
many different
technologies
that use a
great variety of
protocols, and
this is unlikely
to change.
COMMUNITY
JAVA IN ACTION
Conclusion
JAVA TECH
ABOUT US
//embedded /
blog
LEARN MORE
Smartest House on the Street
65
1 THE PROBLEM
2 THE CODE
This program finds the COUNT number of prime numbers that are greater
than some random starting value. It runs slowly because it s not making
effective use of the Stream API. What change could be made that would
result in a considerable speedup?
static final int MAXSEEDVALUE = 200_000;
static final int SEEDVALUE = new Random().nextInt(MAXSEEDVALUE);
static final int COUNT = 10;
System.out.println(
IntStream.rangeClosed(SEEDVALUE + 1, MAXSEEDVALUE)
.parallel()
.filter(i -> IntStream.range(2, i)
.filter(j -> i % j == 0)
.count() == 0)
.limit(COUNT)
.mapToObj(String::valueOf)
.collect(Collectors.joining(" ")));
COMMUNITY
JAVA IN ACTION
JAVA TECH
ABOUT US
//fix this /
1) R
eplace the lambda expression (j -> i % j == 0) by an anonymous class
implementing the IntPredicate interface.
2) Move the limit() function before the outer filter().
3) Use noneMatch() instead of the inner filter().
4) Replace both filter() functions using the iteration of the Java
Collections Framework.
blog
Look for the answer in the next issue. Or submit your own code challenge!
66