XUL HelloWorld Application
by Vijay Kiran
XUL Applications
As described already XUL applications need XUL Runtime, which can be any mozilla browser instance. But for starting XUL Application as a seperate standalone application, we can use XULRunner. Similar to the JRE, xULRunner provides the runtime environment for the XUL application. For development purposes, we can use the XUL App Directory Structure. The deployment/installable package structure will slightly differ from this setup. The deployment will be explained in a later section.
Development Package Structure
The following is the package structure for creating a standalone application. The application.ini will have the initial settings for the application. The chrome folder is the place where all the interface(XUL), and behaviour(JS) is kept. The chrome folder can be delivered as a JAR file as well.
helloworld/
application.ini
chrome/
chrome.manifest
content/
helloworld/
--- XUL and JavaScript files. ----
locale/
en-US/
helloworld/
--- DTD files for en-US locale ---
skin/
helloworld/
-- CSS for styles etc. ---
defaults/
preferences/
helloworld-prefs.js
The main folders of a chrome package are content, locale and skin.
Content – Windows and scripts
The content folder contains all the windows defined using XUL and corresponding behaviour files defined in JavaScript files. The main XUL file should have the same name as the application folder, in our case it should be helloworld.xul. Generally scripts are placed in seperate JS files.
Locale – Locale specific files
The mozilla applications support internationalization using locale. You can use locale folder to create different DTD files for different locales. The locale can be switched in the runtime.
Skin – Style sheets, images and other theme specific files
Stylesheets alontg with images can be used for skin of the application, in this way its very easy to make the interface skinnable. It’s very useful if you want your application to be customizable look and feel.Previously an RDF format file is used to manifest the contents of the package. But since Firefox 0.9 the format has changed to plain-text file chrome.manifest.
Here are the steps to create the HelloWorld application
- First download the XULRunner from >here
- Extract the XULRunner to the hard disk (C:\xulrunner).
- Download the helloworld.zip attached with this article. You can even create your own application structure as explained below. But starting with the skeleton pakcage will give you more flexibility.
- Extract the helloworld.zip to the hard disk (C:\helloworld).
- Run the application using the command c:\xulrunner\xulrunner.exe c:\helloworld\application.ini
