Installing FreeMarker

At the time of writing this book, the latest production version of FreeMarker is 2.3.19. If you are using a newer version, check the release notes for changes. The FreeMarker project sometimes introduces changes that are not compatible with the behavior of the previous versions. If your version starts with 2.4, it's likely that such changes have been made.

Even if you incorporate FreeMarker from a repository, it's worth getting a copy of the documentation for reference. There is also some example code which we will want to walk through when we start looking at integration with web applications.

Step 1 – what do I need?

In order to incorporate FreeMarker into your project, you need a single jar file, freemarker.jar. This, and great deal of additional material, can be downloaded as a bundle from the FreeMarker site at http://freemarker.sourceforge.net/freemarkerdownload.html.

Step 2 – downloading FreeMarker

The file you'll download will be a GZIPed TAR file, so you'll need an appropriate tool to unpack it. Such tools are standard on Linux, but you'll need a third-party tool such as WinZip or 7Zip for Windows. After you have unpacked the contents, the freemarker.jar file will be under the lib subdirectory. You can copy that file to wherever you need it. The examples we will be working through are designed to work in a simple, flat directory, so that you can create a directory to work through these examples and copy the JAR file to it.

If you are using a Maven-style repository, use the following artifacts to incorporate FreeMarker into your project:

<dependency>
  <groupId>org.freemarker</groupId>
  <artifactId>freemarker</artifactId>
  <version>2.3.19</version>
</dependency>

Although the download bundle comes with a lot of files, the only one you'll need is the freemarker.jar.

And that's it

Once you have copied that into your project, you are ready to start using it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.158.36