Naked Objects
By Richard Pawson and Robert Matthews

Making the objects available to the user

Creating a standalone executable demo

Having written a Naked Objects application, either as an exploratory prototype or as a delivered system, it is sometimes convenient to be able to share it with others in the form of a self-contained freestanding executable demonstration (one that does not require the prior installation of the framework, the management of source code and other resources, or any infrastructural services).

To create such an executable demo:

  • First, ensure that you have created an application using the org.nakedobjects.Exploration class as your superclass.

  • Create any instances that you require programmatically, as was shown above.

  • Make a copy of the nakedobjects.jar file as provided in the lib directory in the distribution you downloaded. Name this copy so it indicates that it is your application e.g. booking-demo.jar.

  • Create a text file called manifest and place the following line within it, but specifying your application's fully qualified class name.

  • Extract the Log4J classes so they can be included in your new jar file.

    jar -xf log4.jar
  • Update the new jar file so that it includes your application's classes and images, the Log4J classes, and adds the manifest details into its manifest file. Following the booking example, if the images are in the images directory and all the classes are within the ecs directory, then you will run the jar utility with the following options:

    jar -umf manifest booking-demo.jar images ecs org
  • Now the only file that needs to be distributed is the jar file booking-demo.jar. To run the application using Java version 1.2 or later, invoke Java using the -jar flag, for example:

    java -jar booking-demo.jar

    To make it even easier, put this into a batch file or a script. Indeed, if Microsoft Windows is suitably configured, the file's icon can be double-clicked to start it.

    If one of the more recent versions of Java is not available then the application can also be run using version 1.1. However, the Java class library has to be loaded manually and the class to run must be specified, as shown below:

    java -cp <path-to-java>\lib\;booking-demo.jar

    (This command should all be on a single line.)