For the latest version or to report bugs visit: https://freemarker.apache.org/
Apache FreeMarker is an effort undergoing incubation at The Apache Software Foundation (ASF). Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
By sending a pull request you grant the Apache Software Foundation sufficient rights to use and release the submitted work under the Apache license. You grant the same rights (copyright license, patent license, etc.) to the Apache Software Foundation as if you have signed a Contributor License Agreement. For contributions that are judged to be non-trivial, you will be asked to actually signing a Contributor License Agreement.
FreeMarker is a “template engine”; a generic tool to generate text output (anything from HTML to auto generated source code) based on templates. It‘s a Java package, a class library for Java programmers. It’s not an application for end-users in itself, but something that programmers can embed into their products. FreeMarker is designed to be practical for the generation of HTML Web pages, particularly by servlet-based applications following the MVC (Model View Controller) pattern.
FreeMarker is licensed under the Apache License, Version 2.0.
See the LICENSE file for more details!
Online: https://freemarker.apache.org/docs/
Offline: The full documentation is available in the binary distribution in the documentation/index.html directory.
If you are using Maven, just add this dependency:
<!-- Attention: Be sure nothing pulls in an old dependency with groupId "freemarker" (without the "org."), because then you will end up with two freemarker.jar-s and unpredictable behavior on runtime! --> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>{version}</version> </dependency>
Otherwise simply copy freemarker.jar to a location where your Java application's ClassLoader will find it. For example, if you are using FreeMarker in a web application, you probably want to put freemarker.jar into the WEB-INF/lib directory of your web application.
FreeMarker has no required dependencies. It has several optional dependencies, but usually you don‘t have to deal with them, because if you are using an optional feature that’s certainly because your application already uses the related library.
Attention: If you upgrade to OpenJDK 9 or later, and you are using XPath queries in templates, you will need to add Apache Xalan as a dependency, as freemarker.ext.dom can‘t use the XPath support included in OpenJDK anymore. It’s not needed on Oracle Java 9, or if FreeMarker is configured to use Jaxen for XPath.
The minimum required Java version is currently Java SE 5. (The presence of a later version may be detected on runtime and utilized by FreeMarker.)
Online (for stable releases only): https://freemarker.apache.org/docs/app_versions.html
Offline: In the binary release, open documentation/index.html, and you will find the link.
If you haven't yet, download the source release, or checkout FreeMarker from the source code repository. See repository locations here: https://freemarker.apache.org/sourcecode.html
You need JDK 8 (not JDK 9!), Apache Ant (tested with 1.9.6) and Ivy (tested with 2.4.0) to be installed. To install Ivy (but be sure it's not already installed), issue ant download-ivy
; it will copy Ivy under ~/.ant/lib
. (Alternatively, you can copy ivy-<version>.jar
into the Ant home lib
subfolder manually.)
It's recommended to copy build.properties.sample
into build.properties
, and edit its content to fit your system. (Although basic jar building should succeeds without the build.properties file too.)
To build freemarker.jar
, just issue ant
in the project root directory, and it should download all dependencies automatically and build freemarker.jar
.
If later you change the dependencies in ivy.xml
, or otherwise want to re-download some of them, it will not happen automatically anymore, and you must issue ant update-deps
.
To test your build, issue ant test
.
To generate documentation, issue ant javadoc
and ant manualOffline
.
Below you find the step-by-step setup for Eclipse Mars.1. If you are using a different version or an entierly different IDE, still read this, and try to apply it to your development environment:
ant clean jar ide-dependencies
(Note that now the folders ide-dependencies
, build/generated-sources
and META-INF
were created.)