Applet Plugin

  • Tags : rich client, applet
  • Latest : 0.1
  • Last Updated: 10 March 2009
  • Grails version : 1.1 > *
  • Authors : Mingfai Ma
1 vote
Dependency :
compile ":applet:0.1"




This plugin provides a "grails package-applet" task to build, pack, and sign Applet jars by configuration.


  • Simplify Applet development by providing a script to automate building, packing, signing and deployment
  • automatically includes classes by introspection
    • In another words, you put the applet class in the configuration, and the plugin will automatically find the classes that your applet class uses, and include them in the applet jar
    • this feature is powered by Autojar
    • remarks: it doesn't work for some dynamic Groovy usage
  • support multiple applet jars

Installation and Configuration

  • Installation
    • grails install-plugin applet
    • set JAVA_HOME and PATH correctly
  • Key Generation
    • This plugin does not generate any key or certificate for you. Before running the package-applet command, you need to use keytool to generate a key and create a cert. For JDK on Windows, you may run the following commands:
      1. keytool -genkeypair -alias <alias> -storepass <password>
      2. keytool -selfcert -alias <alias> -storepass <password>
  • jar configurations
    • The 2nd thing you need to do is to add a piece of configuration in grails-app/conf/Config.groovy
    • multiple jars could be defined under plugins.applet.jars, e.g.
      plugins {
        applet {
          //groovyJar = 'C:/groovy/groovy-1.6.0/embeddable/groovy-all-1.6.0.jar'
          jars {
            'demo1.jar' { // leading '/' is optional
              groovy = true; // set to false to skip including groovy-all-* in the jar
              classes = ['demo.applet.*.class']
              sign {
                alias = 'default' //your alias in keystore
                storepass = 'password'//alternatively, use a system property with -Dstorepass=password
              pack200 = true
    • The above configuration will create, pack, and sign a demo1.jar under web-app/. To create the jar in another path, create the parent folder manually, and change 'demo1.jar' to 'yourfolder/demo1.jar'
    • Notice that applet classes are loaded from the same classpath as same as the Grails server application. It's not hard to add scripts to compile and get classes from another classpath, however.

Use the jar

  • if the demo1.jar is under root and the jar is accessible at http://localhost:8080/appletApp/demo1.jar, you may load it with the following html:
      <script src=""></script>
      var attributes = {
        width:300, height:100} ;
      var parameters = {fontSize:16} ;
      var version = '1.6' ;
      deployJava.runApplet(attributes, parameters, version);


Need more features?

  • Send a message to me or the grails-user list and contribute the feature you want.
Author: Mingfai Ma ( (at-no-spam)