dimanche mars 14, 2010

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 -127 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 (-127, 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 !  

samedi févr. 06, 2010

Oracle + Kenai : clarifying the message ...

Last week, when publishing a serie of webcasts explaining the Oracle + Sun product strategy, Oracle clearly announced the end of Sun's sponsored source forge Kenai.com.

Today, Oracle sent a very different message to the community and recognized they poorly communicated about this.  To summarize it : current plans are to reuse Kenai.com infrastructure to power another Sun's sponsored source forge : java.net (hosting projects such as GlassFish, OpenSSO and OpenESB amongst others).

Communities and projects currently hosted on Kenai.com will be migrated to Java.net 

Is it really a poorly executed communication ?  Or does Oracle step back due to community feedback ?

Should the later be correct, this is a good sign that Oracle is (very) quickly learning how to deal with the many communities it inherits when acquiring Sun Microsystems. 

lundi févr. 01, 2010

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.

mercredi janv. 13, 2010

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 !

mardi janv. 12, 2010

Java EE 6 online code camp is starting today

The first online Java EE 6 code camp is starting today, it is not too late to register.

The objectives of this code camp is to let you practice and code, code, code using key Java EE 6 technologies.

Online mentors (top notches guys from the Java community) will be available online to answer your questions.

One more thing : this is entirely free, so do not hesitate and register today

mardi oct. 13, 2009

WS-Security with GlassFish ESB

When selling GlassFish ESB to partners, we (Sun) have to provide our partners with all the material allowing them a quick ramp-up on our technology.  That's the main reason why my group (Sales Engineers, Northern Europe) created a 3 days GlassFish ESB technical workshop.

My contribution to this workshop is a one hour module about WS-Security and GlassFish ESB (and OpenESB).  The idea is to demonstrate how easy it is to setup a WS-Security enabled channel between a web service provider and a web service client.

Specifically, the screencast tutorial shows how to establish mutual certificate authentication between an EJB based web service and a JBI service assembly, acting as web service client, in this case, a BPEL module.

The module is now released online, booth as PDF slides and as a screencast tutorial.

To learn more about WS-Security, I recommend this reading.

Enjoy ! 

lundi juil. 27, 2009

JavaFX presentations and demo during our last JUG meeting

A couple of days ago, the Luxembourg Java User Group - YaJuG - and the Lorraine JUG held a last meeting before the holiday season.  They invited Simon Ritter and myself to talk about ademo JavaFX.

The meeting was organized on a boat (une péniche) usually dedicated for theatre performances

The slides are now posted on YaJuG's web site while Lorraine JUG posted some pictures on Picassa.

French local newspaper "Le Républicain Lorrain" wrote a short paper about this and even sent a photograph for the occasion (lower left of the page, in french !). 

lundi juin 15, 2009

Fun with JavaFX, how to subclass UI controls

While I was doing a JavaFX demo to a group of partners, someone asked the questions : "Does JavaFX provides more specialized UI controls, like SearchTextBox, Table etc ... ?"

As of today, JavaFX 1.2 proposes this list of controls and, of course, it is relatively easy to subclass these to get the behavior you want.

But I wondered how easy it really might be, so I tried.

My goal was to create a "Search Text Box", you know ?  These TextBoxes used in Apple's iTunes for example to clearly indicate that this control is to search.

It has a small glass in the front of the text area and a "cancel" button appears when text is typed to allow user to reset it's content in a click.

It took me a couple of hours to create it, here is the result on the right side. 

I basically extended JavaFX 1.2 TextBox control and added two groups :

  • One is the "Cancel" button, made of gray Circle and two Rectangles
  • The other is the glass, made of one Circle and one Rectangle

I positioned these inside the TextBox, relatively to the original control's size.

I added two callback functions to notify about possible events : new search text is available (onSearchItemAvailable) and search is reset (onResetSearch).

I finally struggled a little bit to find a way to prevent text to draw itself beneath these two icons.  It was solved using the skin's padding-left and padding-right CSS attributes (Thanks Philippe from Sun's Developpers Forum to point me in the right direction).

You can download the full source code here or you can start the test application directly from this page by clicking on the image below.

As usual, comments and remarks are welcome.

mardi mai 12, 2009

Next JUG Event : Java & Web Applications Security

The next YaJuG (the Luxembourg Java User Group) event will cover some security topics for Java developers :

  • How to  implement cryptography (encryption, key generation, signature, etc.) from within your Java applications
  • A review of the Java top-10 security breaches in your web applications.

More details and registration are available online.  Book your agendas : May, the 27th 2009

jeudi avr. 02, 2009

JavaONE 2009

Lab 5557 : Building JavaFX clients for RESTful and JSON based web services.

I'm Speaking At JavaOne

Rich Internet Applications - RIA - do require a strong service access and data access layer located on the back-end, just as traditional or web based applications. It is therefore essential to combine desktop technologies and server technologies in order to provide fast, efficient and secure access to your data.

This lab will teach students how to combine desktop technologies, such as JavaFX™ technologies, and back-end technologies, like web services and REST based services to build state of the art desktop applications.

This lab will go through a very simple example of REST data retrieval and a Java FX graphical representation of these data.

This lab will use the following technologies :

  • RESTful web service and JSR 310 (Jersey) API on the server side
  • JavaFX on the client side

The JavaFX application will asynchronously poll RESTful web services to collect data that will be used to dynamicaly update the client rich UI.

vendredi févr. 20, 2009

Luxembourg Java User Group - Fun with Lego, Wii and Bluetooth

Last Tuesday, the Luxembourg Java User group (YaJuG) held its first 2009 meeting and the agenda was quite fun.

The slides (in french) are available and the full video of the sessions will be posted soon.

A short, one minute, video overview of the evening is also published.


    lundi janv. 19, 2009

    JavaFX asynchronous communication with JSON and REST based web services

    While writing Rich Internet Application with JavaFX is relatively easy and well documented, fetching data from remote sources seemed more obscure to me. The documentation is minimal and I did not found any good tutorial describing the various techniques available to connect to a remote web service and how to parse the results.

    While this blog entry do not aim at being such a tutorial, I will just give an example I developed over the week end to integrate a JSon based REST web service from a JavaFX application.

    (For those of you interested in database access, my colleague Octavian just published a blog entry on the subject).

    Let's first start with the REST web service. Once you have installed the appropriate plugin into NetBeans, it is as simple as creating a web application, then creating a REST based web service.

    I used the json.org supplied JSon Java classes to create the output message.

    The web service I created just return 4 random values, between 0 and 100. The syntax of the returned message is

    {“Values”: 21, 35, 76, 82}

    And the code is as follow :

    public class ValuesResource {
        Random rand = new Random(new java.util.Date().getTime());
        public String getValues() {
          String result;
          try {
             result = new JSONStringer()
          catch (JSONException e) {
             result = "{ \\"error\\" : \\"" +e.getLocalizedMessage() + "\\" }";
          return result;

    I deployed this on GlassFish v3 and tested from command line with curl :

    marsu:~ sst$ curl http://localhost:8080/WebApplication1/resources/values

    In my JavaFX application, I want to call this web service on a regular basis. I therefore choose to use the Timer and TimerTask Java classes to wrap the calling code and execute it on a regular time-based interval.

    The first piece of code is a custom TimerTask. It wraps the JavaFX provided RemoteTextDocument, a very easy to use class that wraps the HTTP communication.

    var values : Number[];
    class Task extends TimerTask {
       override function run() {
          var request : RemoteTextDocument = RemoteTextDocument {
             url: "http://localhost:8080/WebApplication1/resources/values";
          var returnValue: String = bind request.document on replace {
             if (request.done) {         
                var data : JSONArray = new JSONObject(returnValue).getJSONArray("Values");
                for (i in [0..data.length() - 1]) {
                   insert data.getDouble(i)into values;

    The RemoteTextDocument as three useful attributes :

    • url, the URL to connect to ;

    • done, a flag indicating that the connection is completed ;

    • document, the text returned by the URL connection

    The URL connection is made automatically when creating an instance of the class.

    To get access to the document in an asynchronous way, I am using the bind and on replace capabilities provided by JavaFX.

    My returnValue variable is bound to request.document, meaning that every time request.document is modified, returnValue is updated to reflect the new value.

    The on replace trigger, allows to execute some code when the value of returnValue is changing, basically, it parses the resulting String with the Java based JSon classes and create an array of Number.

    Easy to write, to read and very efficient !

    The last step is to create a Java Timer to trigger the TimerTask on a regular basis. I want this process to start as soon as the JavaFX application starts. JavaFX does provide a run() function for this purpose.

    function run( args : String[] ) {
       def timer : Timer = new Timer("TimerThread");
       def task  : Task = new Task();  
       //run the TimerTask immediately and every 5 secs
       timer.schedule(task, 0, 5000);
       //more JavaFX line of code, notably create the Stage and Scene etc ...

    Et voila ... the JavaFX application will start polling the REST web service every 5 secs.

    I further bounded the array of Number prepared by the TimerTask to a PieChart component. The net result is a self-refreshing pie chart as shown below.

    The PieChart JavaFX component will be described in a later blog entry.

    lundi nov. 17, 2008

    Platform Popularity and Job Posting

    One of the interesting way to mesure the popularity of a software platform or framework is to capture the number of job posting requiring experience with the platform or the framework.

    This is the type of search indeed.com allows to conduct.  And guess what ?  GlassFish experience appearing in job postings increased ~700% during the last two quarters !  More than 6 times the growth of popularity of the other application servers.

    Stil looking for evidences of GlassFish adoption ?

    lundi oct. 20, 2008

    Happy Birthday NetBeans

    This week, NetBeans is turning 10 years old.  Join me in congratulating our team and all persons involved on that project during the last decade.

    I still can remember this day when I first downloaded NetBeans 1.0 beta.  At that time I was using a Windows based Java text editor, Kawa ... and Symantec and Microsoft where the masters of the Java IDE world with Symantec Cafe and Visual J++.  For a full review of the Java IDE 10 years ago, read this article.

    You can read the original NetBeans press release on lwn.net.

    mercredi août 27, 2008

    Seeing you in Wonderland

    We just recorded a small demo of Wonderland collaboration.

    Wonderland is a 3D world allowing for team collaboration.

    • You can see and ear other people in the same room, they can see and ear you as well
    • You can see applications (Slideshow, PDF, Office, ...) running on the server or on your desktop
    • Anyone can take control of an application to show something to others
    As soon as the screencast we've recorded is ready, I will post the link.  Jason's blog has more details, including the screencast we've recorded.

    The best part is that Wonderland server is open-source under a GPL license, you can download it and start experimenting with it (available for Solaris, Mac, Linux and Windows).

    Enjoy !

    Sébastien Stormacq is a Senior Software Architect at Sun Microsystems. He uses his 15+ years of professional experience to design large scale, secured and highly transactional architectures based on Sun's middleware solutions.


    « février 2017