Building Qooxdoo applications with Java

November 8th, 2011 | Posted by charless in Build | System

Qooxdoo is a universal JavaScript framework to build rich, interactive applications (RIAs),  native-like apps for mobile devices, light-weight traditional web applications or even applications to run outside the browser. It comes with an integrated tool chain to develop and deploy applications, written in Python.

In this post, I will show you how to build a Qooxdoo application in Java, without the need of a Python interpreter, based on the Qbt Java tool.

requirements

All the shell examples are executed on a mac; they should work as well on linux with a bash. For windows, the qbt launcher is named qbt.bat.

Setting up your local environment

Required environment

charless@mac:~$ WORKDIR=/Users/charless
charless@mac:~$ cd $WORKDIR
charless@mac:Work$ $ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)

Install Qooxdoo Sdk

Summary

  1. Download the distribution
  2. Unzip to the directory of your choice
  3. Export an environment variable named QOOXDOO_PATH that points to the unzipped directory

Example on mac (assuming you have downloaded the sdk from a web browser):

charless@mac:Work$ unzip /Users/charless/Downloads/qooxdoo-1.4.2-sdk.zip
charless@mac:Work$ export QOOXDOO_PATH=./qooxdoo-1.4.2-sdk/
charless@mac:Work$ cd $QOOXDOO_PATH
charless@mac:qooxdoo-1.4.2-sdk$ ls
application    documentation    index.html    readme.txt    version.txt
component    framework    license.txt    tool

Install QBT

Summary

  1. Download the distribution (choose the linux distribution for mac)
  2. Unzip to the directory of your choice (better if the directory is in your PATH)

Installation example on mac:

charless@mac:~$ mkdir -p bin
charless@mac:~$ cd bin
charless@mac:bin$ curl -C - -O \
downloads.charless.org/qooxdoo-build-tool-1.4-alpha-distrib-linux.zip
(...)
charless@mac:bin$ unzip qooxdoo-build-tool-1.4-alpha-distrib-linux.zip
Archive:  qooxdoo-build-tool-1.4-alpha-distrib-linux.zip
inflating: qooxdoo-build-tool-1.4-alpha-qbt.jar
inflating: qbt
charless@mac:bin$ rm qooxdoo-build-tool-1.4-alpha-distrib-linux.zip

Read the qbt setup guide to see how to install qbt on others platforms. You can also build the tool yourself by using Maven.

Make sure you have installed the qbt launcher in a directory that is defined on your PATH, so you will be able to launch qbt from anywhere.

Create a qooxdoo application

Summary

  1. Go to a working directory
  2. Launch qbt create-application -n applicationName [options]

The only required option is -n, to specify the application name. A directory containing the qooxdoo application will be created with the application name. We will name the created directory the qooxdoo-application root directory.

To see the list of all supported options, run qbt create-application.

Example on mac:

charless@mac:qooxdoo-1.4.2-sdk$ cd $WORKDIR
charless@mac:Work$ echo $QOOXDOO_PATH
./qooxdoo-1.4.2-sdk/
charless@mac:Work$ qbt create-application -n myQxGuiApp
[INFO ] QOOXDOO_PATH resolved from 'QOOXDOO_PATH env variable'
[INFO ] Initializing Jython...
[INFO ] Jython initialized in 2 seconds
[INFO ] Starting 'create-application.py -n myQxGuiApp'
(...)
[INFO ] DONE in 3 seconds
charless@mac:Work$ cd myQxGuiApp/
charless@mac:myQxGuiApp$ ls
Manifest.json    config.json    generate.py    readme.txt    source

I did have the following exception on mac, at the end of the creation process:

Exception in thread "Jython Shutdown Closer" java.util.ConcurrentModificationException

Ignore it, it does not affect the creation process (need to be investigated however).

Manage build lifecycle with qbt console

Qbt comes with two modes: a batch mode and an interactive mode.

Using batch mode, you can create a qooxdoo application, run build jobs or execute a qooxdoo python script (such as the migrator.py).

The interactive console must be launched from a qooxdoo-application root directory and is only intended to run build jobs. It will start a Jython interpreter configured to run qooxdoo jobs. You can execute Python and Java code from the console.

Start the console

Summary

  1. Go to a qooxdoo-application root directory (in previous example, the myQxGuiApp directory)
  2. Launch qbt

Example on mac:

charless@mac:myQxGuiApp$ qbt
[INFO ] QOOXDOO_PATH resolved from 'config.json'
[INFO ] Entering interactive console, please wait...
(...)
============================================================================
QOOXDOO INTERACTIVE CONSOLE
============================================================================
›››
terminate with Ctrl-Z (Windows) or Ctrl-D (Unix)
Type:
‹jobname›() or jobs("‹jobname›") to run a single job
jobs("jobname1","jobname2",...) to run multiple jobs once
jobs("x") to see the lists of possible jobs
Example to clean and compile the production version:
clean()
build()
Or:
jobs("clean","build")

Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_26
›››

Build the application

With Qooxdoo, you can build a production version and/or a development version:

  • - The production version will create a single js-compressed javascript file with all the required dependencies (you may have multiple files if you are using parts); you need to rebuild the application each time a source file is modified/created
  • - The development version works on the source files; once builded, you can work on the sources and test your development by refreshing your browser; you need to rebuild the sources only when a new source is created (or, depending on the build options, when you use a new qooxdoo framework dependency)

Build the production version

Summary

  1. Launch build() from the console prompt
  2. Open a browser and go to file:///path/to/qooxdoo_application_root_dir/build/index.html

Example:

››› build()
(...)
››› Jobs: ['build'] done in 129.23 seconds

Build the development version

Summary

  1. Launch source() from the console prompt
  2. Open a browser and go to file:///path/to/qooxdoo_application_root_dir/source/index.html
  3. Try to change the code in /path/to/qooxdoo_application_root_dir/source/class/myqxguiapp/Application.js and refresh the page

Create the Test Runner for running unit tests

Qooxdoo let you write unit tests and run them from the Test Runner, a unit testing framework that fully supports testing qooxdoo classes (see the Test Runner in action in the online demo).

Summary

  1. Launch test() from the console prompt
  2. Open a browser and go to file:///path/to/qooxdoo_application_root_dir/test/index.html

Generate the API

The API viewer is another great application that will generate the API documentation of your application (Online demo).

Summary

  1. Launch api() from the console prompt
  2. Open a browser and go to file:///path/to/qooxdoo_application_root_dir/test/index.html

Conclusion

Qbt is the right tool  if you haven’t a Python interpreter installed but want to get started quickly with the development of Qooxdoo applications.

Qbt is a wrapper to the qooxdoo Python tool chain, and so supports the same functionalities; it is however slower than the traditional approach of using a real Python interpreter; think of installing such an interpreter on your system if the building process is too slow for you.

A qooxdoo application build can be configured in many ways, and there are many others jobs that were not covered in this post. Make sure to read the qooxdoo documentation to see all the possibilities offered by this great framework.

I am sure you will enjoy developing Qooxdoo applications !

 

 

Share and Enjoy

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>