Jspresso in 10 minutes

For the lazy ones : the screencast

Installing the required tools

This is probably the longest part of this step-by-step introduction. Download and install the following tools :

  • the Java Development Kit for your platform (JDK 6+). Install location referred below as ${JAVA_HOME}.
  • the Apache Maven project management tool (3.0.3+). Install location referred below as ${MAVEN_HOME}.
  • the AT&T Graphviz graph visualization tool (2.17+). Install location referred below as ${GRAPHVIZ_HOME} only useful for documenting Spring beans through beandoc.
  • a Python 2.5+ runtime (Windows users, you can use ActivePython) available from the user path.

 

Configure Maven launch script to point to ${JAVA_HOME} and setup your path to include the "bin/" directory.

You must also increase the java heap space allocated to Maven :

on windows :

set MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m (or set it as a user env variable)

on linux :

export MAVEN_OPTS=-Xmx512m -XX:MaxPermSize=128m (or set it as a user env variable)

 

Generating the application project

  • Create a new empty directory to host your projects (e.g. "~/workspace"). This directory will be referred below as ${WORKSPACE}.
  • Move to ${WORKSPACE} and type the following command :
mvn archetype:generate -DarchetypeCatalog=http://repository.jspresso.org/maven2/

This instructs Maven to go to the Jspresso Maven repository to look for application archetypes. The output should be something like :

[INFO] Scanning for projects...
...
Choose archetype:
1: ... -> jspresso-archetype (Jspresso CE Archetype)
...
Choose a number:  (1):
  • Select the Jspresso application archetype by typing "1". It is now time to configure some important values in your project :
Define value for groupId: :
  • Type in the group id of your new project : com.example.helloworld
Define value for artifactId: :
  • Type in the artifact id of your new project : helloworld
Define value for version:  1.0-SNAPSHOT: :
  • Confirm the default value.
Define value for package:  com.example.helloworld: :
  • Confirm the default value.

Maven outputs the following to let you review the project settings :

Confirm properties configuration:
jspressoVersion: 3.5.5
graphvizExecutable: C:/envdev/graphviz/bin/dot.exe
applicationDescription: Example Application Description
companyUrl: http://www.example.com
applicationName: Example Application
companyName: Example Company
siteDistributionUrl: file:///tmp/maven-site
groupId: com.example.helloworld
artifactId: helloworld
version: 1.0-SNAPSHOT
package: com.example.helloworld
 Y: :

There are certainly default settings to change, so answer "N". Review all the questions and adapt the answers to your environment. Pay special attention to the following property (only if you want to document your Spring beans with Maven site plugin) :

  • graphvizExecutable must point to ${GRAPHVIZ_HOME}/bin/dot[.exe]

Of course, you are free to change company name and URL, application name, and so on. Maven should re-output the property values and you can now validate ("Y") and launch the generation process. Wait for the "BUILD SUCCESSFUL" output.

You should now have a new directory helloworld generated. This is the maven project directory of your application. Everything is properly configured for you to work, package, install and generate documentation.

 

Building and packaging the application

Move to the new generated helloworld project directory and type :

mvn package

This command may take some time to execute since Maven must download and install all the required plugins and dependencies in the machine local repository, so be patient and wait for the "BUILD SUCCESSFUL" output. Plugins and dependencies downloading is a one-time process since everything is now locally cached.

You should now have your webapp archive built and ready to be deployed. it is located here :

helloworld/webapp/target/helloworld-webapp.war

 

Running the application in the embedded servlet container

Your new project is preconfigured to run an embedded Jetty application server. Just start it with :

mvn jetty:run-exploded

 

Your Jspresso application is now accessible, with login demo/demo.

For the qooxdoo version, point your browser at :

http://localhost:8080/helloworld-webapp/qooxdoo/

For the Adobe's Flex version, point your browser at :

http://localhost:8080/helloworld-webapp/flex/

Congratulations! You have created, packaged and deployed your first Jspresso powered application. It's rather minimalistic but all the layers are here and working together :

  • HSQLDB in-memory database
  • Hibernate
  • Spring
  • Flex, qooxdoo, Swing
  • Binding, I18N, ...

If you give us a few more minutes, we will develop a small CRUD application. But don't forget that Jspresso is much, much more than a CRUD framework. Take a look at the documentation as well as the various screenshots and live demos to get a better understanding of it.