Posts Tagged Java

Put a Java Brain into your Lego Robot

Our JavaONE session today went very well.  The room was packed (roughly 150 persons), with people standing in the back.

All demos went well, after a few surprises and tuning 🙂

Comments and questions during the talk were very positive.

As promised to the attendees, here are the slides, the source code of the REST API (as a NetBeans project) and the source code of the iPad application (as an XCode project).

Feel free to leave comments and remarks here.  Thank you for attending and enjoy !

, , , , ,

No Comments

Playing with Lego’s Mindstorms, LeJOS, GlassFish and an iPad

I will co-present three different session, hands-on-lab and BOF during JavaONE 2010.

One of these has actually nothing to do with usual business, it just aims at being fun and at playing with geek toys : we are hosting a BOF about Java programming for the Lego’s Mindstorms, i.e. the LeJOS project.

Neither David or myself are directly involved with LeJOS community, we are just regular users willing to share our experiences with people discovering Lego’s Mindstorms kit and the LeJOS project.

So, if you happen to be around in San Francisco next Wednesday, be sure to stop 45 minutes at 02:15 pm in the Parc 55 Hotel (Room Divisidero)

David will demo how to interface Lego’s NXT brick with an Arduino device.

I will show how to create a iPad controller for a robot, using a REST interface hosted on GlassFish.

Does it sounds geeky enough ? A short videoshow all this in action.

, , , , ,

No Comments

How to Create an Animated JavaFX’s Line Chart ?

Java FX introduced charting components back in 1.2 version : AreaChart, BubbleChart, PieChart, LineChart … you name it.

You will find a good introduction to LineChart capabilities in Rakesh’s blog entry.

One common request found in forums and blogs over the Internet is to create an animated LineChart, i.e. a line based chart where the line is moving from left to right as values are added to the component.

JavaFX.com official website even host an ugly attempt to implement this : by moving a Rectangle over the scene, gradually showing the chart below it. (nope, this is not a joke, go and read it by yourself)

While preparing sessions and labs for the upcoming JavaONE 2010 conference, my colleague David and myself did implement a true Animated LineChart component.

This component exposes a very simple public API :

public function addValue(v:Integer) {}

Each time a value is added to the graph, the line will move to the right side, possibly discarding older values on the left side when the line will reach the graph’s right border.

The magic is done as following : new values are added to the LineChart.Series[0].data[] array.  When the array is filled in (when the number of elements in the array is equal to the number of tick marks available on the X axis), the oldest value (LineChart.Series[0].data[0]) is removed and all values are shifted one position left in the array.

Source code and detailed instructions to build this AnimatedLineChart component will be given during our JavaONE 2010 Hands-On Lab (S616734 currently scheduled for Thursday, 23rd at 12:30 pm at the Hilton) (see UPDATE at the end of this post)

In the meantime, you can have a look at the screenshot below.

[UPDATE : November 2011]

Due to popular demand, and because we learned that Oracle will not make JavaOne’s talk freely available to all, like Sun use in the past, here is the source code for this component.  Enjoy !

AnimatedLineChart.fx

, , ,

2 Comments

A Java library to use Belgium eID cards

Today, I used my Belgium Electronic ID smart card to digitally sign my Tax Declaration.  Nothing new here, it happens now since six years in a row (I just wonder how many countries have setup such an end-to-end digital system, including digital signature, to interact with various administrations).

As every year, I wonder what API and libraries are available to programmatically extract or sign data with the smart card : a bunch of low level PC/SC API calls, a couple of Java-through-JNI samples, but nothing really high level and easy to use.  Most of the examples returned by Google are quite old, not adapted to Java SE 6, not running in 64 bits mode and are not working on Mac OS X … sigh !

This year however was different, Google spotted eidlib, a Java SE 6 native library wrapping operations of the Belgium eID card.

This API is different from all the other I know : it uses the Java SE 6 javax.smartcard i/o framework to directly communicate with the card reader, exchanging APDU as required per the card protocol.

This is by far the easiest to use Java library for eID I found so far.  You just need to include the JAR file into your classpath, then write simple code like :

           BeID eID = new BeID(true); // We allow information to be fetched from test cards

           // We fetch the information
           System.out.println("InformationRetrieval -- ID information:");
           System.out.println(eID.getIDData().toString());
           System.out.println("InformationRetrieval -- Address information:");
           System.out.println(eID.getIDAddress().toString());
           System.out.println("InformationRetrieval -- Photo is saved to file:");
           eID.getIDPhoto().writeToFile(eID.getIDData().getName());

Et voilà … ready to include strong authentication and signature in your own applications.  I tested every example provided on the web site with NetBeans 6.9, using Java SE 6 64 bits on Snow Leopard.

This library was developed by Kristof Overdulve, at that time student at the University of Antwerp, for his Bachelor thesis.  Kuddo !

[UPDATE]

Bart pointed me to this eID Applet project.  If all you wanna do is include eID authentication or signature in your web application, then the eID applet is probably the way to go.

, , , ,

8 Comments

YaJuG’s “Google Night” videos are available

Tonight, Luxembourg’s Java User Group (YaJuG) will host it’s third 2010 conference.  Theme for tonight is “Cloud Computing”.  It is not too late to register.

Should you have missed our previous conferences, do you now that the slides are published on our web site and that the full video content is available, free of charge, on Parleys.com ?

Enjoy !

,

No Comments

Cloud Conference for Java Developers

Next week, Wednesday, 30th the Luxembourg Java User group (YaJuG) will organize a conference : “The Cloud for Java Developers”.

With speakers talking about Amazon Web Service, Google App Engine and SalesForce.com platform, this conference will bring you insights the various major cloud platform types : Infrastructure, Platform or Software as a Service.

This event is sponsored by Lancelot Consulting.

Detailled agenda and registration is available on YaJuG’s web site.

, ,

No Comments

NetBeans 6.9 is released

Java Communities (and Oracle development teams) have been kept busy these days.  After the release of GlassFish Open Source Edition 3.0.1 yesterday, the NetBeans team announces the availability of NetBeans 6.9.

Major new features include

With a download footprint of 52 Mb (28Mb for the PHP only edition), NetBeans remains the most efficient general purpose IDE.

,

1 Comment

Hey Mark, we missed the point here !

I was recently watching Mark Reinhold‘s interview on Oracle Technology Network. Mark is Principal Engineer at Sun Oracle and works on OpenJDK and future Java SE releases.

The interview went over many different subjects around Java SE : projects coin (simplification), jigsaw (modularity), closures (…)

Mark was also insisting on the many –ities of the Java platform : security, availability, scalability, readability, …

One of my favorite is readability ! It is important to understand how a piece of code is expected to behave just by reading it.  This helps to reduce bugs when we write code and / or to easily catch bugs when reading code written by our peers.

Java SE 5, released about 5 years ago, introduced a feature called auto boxing, allowing to mix and match Java’s primitive types (such as int, boolean, …) with their Object counterpart (such as Integer, Boolean, …)

The objective of autoboxing is to simplify code and increase readability and, as such, is a welcome addition. But the devil lies into the details.

The example of code below shows incoherent behavior introduced by auto boxing :

Integer integer1 = 127;
Integer integer2 = 127;
System.out.println(integer1 == integer2); //true

Integer integer3 = 128;
Integer integer4 = 128;
System.out.println(integer3 == integer4); //false

You read it right : the first equality is true, while the second is false.

I would expect either both expressions to be false (Object references never must be compared for equality, my grand mother learned me) Or both expressions to be true (should auto boxing fullfil its promises).

This weird behavior is caused by some compiler optimizations happening behind the scene.  When the compiler is auto boxing values between -128 and 127, it always reuse the same Object instance.  In our example, integer1 and integer2 are therefore references to the same Integer object, hence the first equality.

For values outside of this (-128, 127) range, the compiler creates different Object instances for each reference, even when the values are identical.

We all learned that we should not use object references when comparing values, but auto boxing encourages us to write such code and when doing so, we end up with incoherent behaviors such as the one described above, which can make bugs very difficult to catch.

Hey Mark, if readability is really a concern : we missed the point with auto boxing !

[UPDATE 3 May 2011]

@jplandrain on Twitter points me to the Java specs where this optimization is specified. See the last sentence of the paragraph.

, ,

No Comments

Oracle + Sun : Java Developer Tools and Communities FAQ

Earlier today, Oracle posted a FAQ answering the most common questions regarding development tools and developer comunities.  It addresses questions about java.net, Kenai, GlassFish, NetBeans, JavaONE etc …

This complements the previous Java Development tools FAQ posted last week. 

For more details about Oracle+Sun product strategy, you might have a look at the many webcasts available.

,

No Comments

Java European Roadshow

Java European Roadshow, coming to a city near you ….

Join us to get an insight into recent trends, strategies and applications in the areas of Java and Java for Business. Learn how to keep your Java applications safe, reliable and secure and how to get the best out of your current Java platform, be it embedded, standard or enterprise edition, or Real-Time Java.

Meet and discuss with Sun experts David Hofert, Simon Ritter, Steve Elliott, Alexis Moussine-Pouchkine and others.

Register today !

No Comments