9.5. Obtaining Jakarta Velocity

Problem

You need to use Jakarta Velocity to create templates that can reference variables and object properties and contain limited conditional and iterative control structures.

Solution

You must download the latest version of Jakarta Velocity, and place the Velocity JAR in your project’s classpath. Follow the steps outlined in Recipe 1.1, downloading Jakarta Velocity 1.4 instead of Commons Lang.

Discussion

After downloading the Velocity 1.4 binary release, unzip or untar the archive, and put both the velocity-1.4.jar and velocity-dep-1.4.jar into your project’s classpath. If you have a Maven project that needs to use Jakarta Velocity, add a dependency on Jakarta Velocity with the following section in project.xml:

<dependencies>
  <dependency>
    <id>velocity</id>
    <version>1.4</version>
  </dependency>

  ....other dependencies...
</dependencies>

See Also

To learn more about Velocity, visit the Jakarta Velocity web site (http://jakarta.apache.org/velocity/).

If you have questions about how to use Jakarta Velocity, you can join the http://velocity-user@jakarta.apache.org mailing list. Refer to Recipe 1.2 for instructions on joining a user mailing list. To join the Velocity user mailing list, see the Velocity section of the Jakarta mailing lists page (http://jakarta.apache.org/site/mail2.html#Velocity).

Get Jakarta Commons Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.