For the latest version or to report bugs visit: https://freemarker.apache.org/
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-gae</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 8. (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 and JDK 16 to be installed (and visible to Gradle).
Be sure that your default Java version (which Gradle should use automatically) is at least 16!
If you are building from the official source release (not from source that you got from Git), gradle/wrapper/gradle-wrapper.jar
is missing from that, and you have to add it yourself! You can download it from GitHub source code page! (Or, use your own Gradle installation instead of gradlew
.)
To build freemarker.jar
, just issue ./gradlew jar
in the project root directory, and it should download all dependencies automatically and build freemarker.jar
.
To run all checks, issue ./gradlew check
.
To generate documentation, issue ./gradlew javadoc
and ./gradlew manualOffline
.
To see how the project would be deployed to Maven Central, issue ./gradlew publishAllPublicationsToLocalRepository
, and check the build/local-deployment
directory.
See gradle.properties
for some Gradle properties that you may what to set, especially if you are building a release.
Below you find the step-by-step setup for Eclipse (originally done on Mars.1):
Originally done on IntelliJ IDEA Community 2023.3.2:
“File” -> “Open”: Select the “settings.gradle.kts” within the freemarker root directory.
If the project fails to load (or build), then adjust the following configuration in “File” -> “Settings” -> “Build, Execution, Deployment” -> “Build Tools” -> “Gradle”:
“File” -> “Settings”
/*
and */
lines, and the *
prefixes (to select columns of text, hold Alt while selecting with the mouse.) Then go back to “Copyright” in the tree, and set “Default project copyright” to “ASL2”.