JavaFX + Zembly

Zembly application development environment makes it easy to develop, customize and deploy your application. It provides APIs from various providers.

Here we will try to use Zembly services (outside of Zembly) from JavaFX. Zembly provides client libraries for both Java and JavaFX.

For Applet mode, click on above image

For standalone mode

Above sample is modified version of InterestingPhotos which now uses Zembly APis to search flickr’s photo search based on tags. It uses flickr api – as shown below.

String result = Zembly.getInstance().callService(
    String.class,                 // Return Type
    "",   // Service Name
    new String[][] {              // Arguments
        {"tags""javafx" },

Class com.zembly.gateway.client.Zembly is available in Zembly Client Library implementation. Download here

Now we can easily write a wrapper for zcl in JavaFX using Asynchronous APIs. This will also demonstrate how to use these APIs to invoke Java apis in background thread from JavaFX.

Provide an implementation for javafx.async.RunnableFuture which will invoke the Zembly client APIs – ZemblyRunnableFuture. Next design an interface which bridge the Java and JavaFX – CallbackHandler.

Now we can implement the ZemblyRequest API which extends the JavaFX JavaTaskBase. This will provide an implementation similar to HttpRequest API.

ZemblyRequest can be used in application as shown below

var request = ZemblyRequest {

    // Zembly Service Name
    serviceName: ""

    // Arguments to be passed to service
    arguments: [
        Pair name: "machine_tag_mode", value: "any" },
        Pair name: "tags", value: "{encodedTags}" },
        Pair name: "per_page", value: "65" },
        Pair name: "page", value: "1" },
        Pair name: "format", value: "json" }     

    onStart: function() {
        println("ZemblyRequest - start");

    onInput: function(is) {
        // Use PullParser to parse the stream

    onDone: function() {
        println("ZemblyRequest - done");


Zembly key and secret must be generated and specified in file which must be kept in default package inside jar file. For more information on this, please refer to article – How to Call Data Service from Outside Zembly

I followed articles – Creating a Widget in 5 Minutes and Working with JavaFX so as to deploy above sample as Application

Try it out and let me know feedback


var dzone_url = “”;
var dzone_style = ‘2’;


About Rakesh Menon

3 Responses to JavaFX + Zembly

  1. Raghu Nair says:

    Thanks Rakesh for posting this. I was referring to Zembly APIs yesterday for hosting my facebook app in Zembly and mak it as a app in Facebook. Even though this is diffrent it is very usefull. Your blogs just rocks!!!

  2. Ashok says:

    Whether zembly is IDE like Eclipse or like Twitter API’s ? because name ‘zembly application development environment’ confuses me.

  3. Rakesh Menon says:

    @Ashok Zembly provides APIs, web-based editor, easy integration with Facebook, hosting and collaborative environment. Best place to start is

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: