Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3


The following makes it simple to start a griffon project.

Table of Contents

Create a Griffon project

Once you have installed Griffon you can use the built-in target for creating new projects:

Code Block

griffon create-app

The target will prompt you for the name of your project and create the project structure below:

Code Block

+ griffon-app
+ conf ---> location of configuration artifacts like builder configuration
+ keys ---> keys for code signing
+ webstart ---> webstart and applet config
+ controllers ---> location of controller classes
+ i18n ---> location of message bundles for i18n
+ lifecycle ---> location of lifecycle scripts
+ models ---> location of model classes
+ resources ---> location of non code resources (images, etc)
+ views ---> location of view classes
+ lib
+ scripts ---> scripts
+ src
+ main ---> optional; location for Groovy and Java source files
(of types other than those in griffon-app/*)


Make sure you are in the root directory of your project (for argument sake "DemoConsole", a simple script evaluator) by typing

Code Block

cd DemoConsole

The "create-app" target created a Griffon MVC Triad for you in the models, views, and controllers directory named after the application. Hence you already have a model class DemoConsoleModel in the models directory.


Code Block
package democonsole

import groovy.beans.Bindable

class DemoConsoleModel {

    String scriptSource
    @Bindable def scriptResult
    @Bindable boolean enabled = true



Code Block
package democonsole

import java.awt.event.ActionEvent

class DemoConsoleController {

    GroovyShell shell = new GroovyShell()

    // these will be injected by Griffon
    def model
    def view

    def executeScript(ActionEvent evt = null) {
        model.enabled = false
        doOutside {
            def result
            try {
                result = shell.evaluate(model.scriptSource)
            } finally {
                edt {
                    model.enabled = true
                    model.scriptResult = result


Code Block
package democonsole

application(title:'DemoConsole', pack:true, locationByPlatform:true) {
    panel(border:emptyBorder(6)) {

        scrollPane(constraints:CENTER) {
            textArea(text:bind(target:model, targetProperty:'scriptSource'),
                enabled: bind {model.enabled},
                columns:40, rows:10)

        hbox(constraints:SOUTH) {
            button("Execute", actionPerformed:controller.&executeScript,
                enabled: bind {model.enabled})
            label(text:bind {model.scriptResult})


To start your Griffon app run the following target

Code Block

griffon run-app

This will run the application as a Java application. You can also use the run-webstart target to run the application from a WebStart/JNLP file.

The run-app script implies the execution of the package script. The package script creates file artifacts suitable for a Java application, a WebStart application, and an Applet, with code signed by a self-signed certificate. All from the same source tree. By default they go in the 'staging' directory.

Code Block

ls staging

Try out the applet by bringing up the applet.html file in a browser. Or you can try them out directly by running the following commands

Code Block

griffon run-applet
griffon run-webstart