Moods, Videos

AIR 2.0 and the Enterprise

19 Comments 10 June 2010

AIR 2.0 and the Enterprise

AIR 2.0, available on, is a major release for all Enterprise developers. As you may already know, thanks to Adobe AIR, you can launch a web application outside the browser. It means that you can escape the browser sandbox and its limitations, and give more freedom to your Flex or AJAX applications: access to local files, an embedded SQLite database, drag and drop with documents on the desktop… A lot of large accounts are using AIR 1.5 to run Rich Internet Applications. One of the best use cases is online/offline data synchronisation. Indeed, the Adobe AIR API lets you know when your application is connected or disconnected from the network. Associated to LiveCycle Data Services, an Adobe AIR application can automatically synchronize the changes made on the local dataset while being offline, with a distant application server. is a perfect example. Thanks to Adobe AIR, Salesforce users can read, update, and manipulate the data of this famous CRM while traveling by train or by plane. This feature is absolutely meaningful, especially for a CRM solution. Indeed, the value of a CRM is in the knowledge stored in the database. Using Adobe AIR, Salesforce provides the best user experience for sales reps that travel a lot and need to update the CRM at any time of the day.

AIR 2.0 take Enterprise Rich Internet Applications one step further in the Enterprise world. Several features will help you to extend the limitations of current RIAs. I invite to download and explore the new API of AIR 2.0, but today I’ll focus on two important updates: the NativeProcess API and the UDP procotol.

Native Process API

A lot of companies have existing native code libraries to communicate with specific local devices for instance. Imagine an RIA that needs to get a validation from a Credit Card reader device, or that needs to get the digital signature drawing coming from a WACOM tablet in a bank… There are a lot of use cases. The richness of AIR applications combined with the existing native code on workforce computers can produce first-class applications. With AIR 2.0, developers can extend AIR thanks to the new Native Process API, launching and communicating with native processes written in C language, JAVA, .NET or any language that can run on the targeted OS (Windows, Mac or Linux). This new generation of AIR application communicates with the native application using the standard input (STDIN) and the standard output (STDOUT) streams.

To evaluate the technology, I’ve developed a small prototype. I found an open source Java library that can run OCR (Optical Character Recognition). My idea was to develop an AIR application, launch the webcam, let the user present a printed document, take a snapshot and pass the image to the Java OCR engine. The Java library should return the printed text as a string… Well… the quality of the library is not that good, but the AIR 2.0 Native Process mechanism works well :) Here’s the link to the Java library I used for the sample :

Then I developed a small Java program that waits for the path to the image as an argument, and processes the image with the OCR library. I return the text recognized by Java in the standard output stream:

String text = scanner.scan(image, 0, 0, 0, 0, null, imageCanvas.getGraphics());
System.out.println("[" + text + "]");

In my AIR project, I check if the API is supported by the runtime:


Then I can declare the process and add some event listeners on the standard input and output streams of my process.

process = new NativeProcess();
process.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);

When I click on a button, I launch the process. I’m using here the installed JVM of the OS and adding some parameters to pass. To do so, you can use a Vector AS3 object.

var args:Vector.<String> = new Vector.<String>;







nativeProcessStartupInfo.arguments = args;


Then I just need to display the string transmitted by JAVA on my UI. The content of a Flex TextArea component is binded to the out2 String variable:

private function onOutputData( e:ProgressEvent):void{

out2 += process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);


And here's the "almost convincing" AIR application that can recognize characters using the webcam:

OC-AIR: AIR 2.0, Native Process and OCR from michael chaize on Vimeo.

UDP communications

Another great addition to the AIR API is the UDP protocol. A lot of companies have developed in the past collaborative Java and .NET tools based on UDP instead of TCP. Now, an AIR 2.0 application can start a dialog with these existing tools. To play with the API, you can refer to this excellent tutorial: You'll also discover the advantages and the limitations of UDP compared to TCP.
The steps can be reproduced very easily. The idea is to run a Java program that will listen to UDP packets (DatagramSocket). If the external software sends a string, I print it in the standard output. If the external software asks 'Hi, I'm an AIR2 application. Who are you?', then the Java program will answer back saying 'I'm a pure JAVA software man. Nice to meet you'. Of course, the AIR 2 application will send UDP packets to the Java program, and display the answers. 
Here is a video of my demo. Click here to download the source code of my AIR UDP client, and of my JAVA UDP server.

UDPvideo from michael chaize on Vimeo.

Post to Twitter

Your Comments

19 Comments so far

  1. the video is glitchy, can you fix it please? :(

  2. admin says:

    Oops… Video work fine on my side. With the Vimeo player, you can try to enable or disable HD streaming, and try also the fullscreen mode. I hope it’s fixed now. If not I’ll also upload the videos on Youtube.

  3. Rob Fox says:

    Off topic: How do you get the desktop alerts on spotify?

  4. Thanks very much!! Also, I’d love to look at your Build-An-App-In-A-Week video again. Its the one titled “Connecting a web application to a J2EE backend using Flash Builder 4”.

    Can you post it?

  5. The video quality is great for me. Very nice.

  6. Eric Fickes says:

    Great demos Michaël! AIR2 rocks

  7. Nate Ross says:

    Nice use of AIR 2.0 and Java!

    You should look at a library called Transmission for any AIR 2.0 to Java communication you need. It uses AMF as the message format and contains the logic to start up a Java jar.

  8. admin says:

    Nice ! I’ll definitely try it. Did you use the code in BlazeDS to achieve this library. That’s a great idea !

  9. Nick Saparoff says:

    Great article on UDP! I have a question – with the DatagramSocket is there a security limitation like there is with the socket on remote IPs? If I wanted to contact a remote host on the local network, would it need to have a policy file or does the DatagramSocket not require this additional security parameter?

  10. pooja says:

    Can anyone help me with getting digital ink using the Wacom pen and board to display in flex builder? Thanks!

  11. Mark says:

    COuld this be used to create a captcha bypass?

  12. Hendrik says:

    Hi Michael,
    i am having some trouble with executing a Java lib via native process.

    I can start the -jar file but it seems like the java application is not able to connect to the local network when started via AIR.

    Do you know if there are special restrains for Java when beeing executed in air via nativeprocess??


  13. Raul says:

    Hi Michael,

    Thanks in advance for your post.

    Can i executa the OCR example on adroid device?

    Can you share all OCR code example?



  1. OCR priamo z web kamery - June 11, 2010

    […] Postavené na AIR 2. Ďalšie informácie na blogu Michaël Chaize. […]

  2. Flex learner | Blog | AIR 2.0 and the Enterprise | RIAgora - June 12, 2010

    […] See the article here: AIR 2.0 and the Enterprise | RIAgora […]

  3. 50 resources to get up to speed with the Flash Platform : Mihai Corlan - July 29, 2010

    […] AIR 2 and Enterprise […]

  4. 有助于Flash平台开发提速的50个学习资源 « echo "RenYuan's Blog" - August 6, 2010

    […] AIR2里使用支持远程文件的拖拽功能 •        写多屏AIR apps •        AIR2和企业 •        利用ColdFusion 9.0.1 ActionScript ORM库开发AIR离线应用 •        […]

  5. 有助于Flash平台开发提速的50个学习资源 – 新闻资讯 – 9RIA.com天地会 – 论坛 | 谱曲 - August 8, 2010

    […] AIR2里使用支持远程文件的拖拽功能•        写多屏AIR apps•        AIR2和企业•        利用ColdFusion 9.0.1 ActionScript ORM库开发AIR离线应用•      […]

Share your view

Post a comment

Who am I ?

I'm Michaël CHAIZE, Adobe Flash Platform Evangelist based in Paris. I'm a big fan of Rich Internet Applications and I promote the Flash Platform in the Enterprise world.
You can follow me on twitter:


Follow us on Facebook

© 2018 RIAgora. Powered by WordPress.

Daily Edition Theme by WooThemes - Premium WordPress Themes