Private
Protection
Special Offers
Catalog
Auto donation
Many L2J-family packs are still built with Ant. This guide covers installing JDK 17/21 and Ant, running build.xml targets, how a build file is structured and the most common errors.
If the source root contains a build.xml file, the project is built with Apache Ant. Many L2J packs and their derivatives work this way, especially datapacks and projects that have been developed for years. You set up the environment once, and after that a build is a single command.
| Component | Version | Notes |
|---|---|---|
| JDK | 17 or 21, 64-bit | the required version is set in build.xml: the release or source/target attributes of the javac task |
| Apache Ant | 1.10.x | old versions 1.7–1.9 do not work well with current JDKs |
| Git | current | to get the sources |
JAVA_HOME (Win+R > sysdm.cpl > Advanced > Environment Variables) pointing to the JDK root folder, for example C:\Program Files\Java\jdk-21. No \bin at the end!%JAVA_HOME%\bin as a separate entry to the Path variable.apache-ant-1.10.x-bin.zip from the official Apache Ant website.C:\tools\ant (it should contain the bin and lib folders).ANT_HOME set to C:\tools\ant and add %ANT_HOME%\bin to Path.ant -version
Apache Ant(TM) version 1.10.x compiled on ...On Ubuntu a single command is enough: sudo apt install ant openjdk-21-jdk. To build from an IDE you do not even need a separate installation, since Ant is built into IntelliJ IDEA and Eclipse.
Clone the pack repository with Git (details in the IDE and Git guide). The core and the datapack are often separate projects, each with its own build.xml:
cd D:\l2
git clone CORE_REPOSITORY_URL gameserver
git clone DATAPACK_REPOSITORY_URL datapackIf the project is still kept in SVN, the command is similar: svn checkout URL folder.
A target is a named set of actions: clean, compile, package. ant -p lists the targets with their descriptions:
cd D:\l2\gameserver
ant -p
Buildfile: D:\l2\gameserver\build.xml
Main targets:
clean Remove build output
compile Compile sources
dist Build the server into build/dist
Default target: dist| Command | What it does |
|---|---|
ant | runs the default target (the default attribute of the project tag) |
ant dist | runs a specific target |
ant clean dist | runs several targets in order: clean, then a full build |
ant -f D:\l2\datapack\build.xml | builds using a file from another folder |
ant -v dist | verbose output for troubleshooting |
ant -logfile build.log dist | saves the build output to a file |
A successful build ends with BUILD SUCCESSFUL and Total time. The output usually appears in the build/ folder: compiled classes, the core jar, a ready distribution and/or a zip archive. The exact paths are defined by the properties at the top of build.xml and by the distribution target.
A simplified but working build file for a game server:
<?xml version="1.0" encoding="UTF-8"?>
<project name="L2GameServer" default="dist" basedir=".">
<description>Game server build</description>
<property name="src" location="java"/>
<property name="lib" location="lib"/>
<property name="build" location="build"/>
<property name="build.classes" location="${build}/classes"/>
<property name="build.dist" location="${build}/dist"/>
<path id="classpath">
<fileset dir="${lib}" includes="*.jar"/>
</path>
<target name="clean" description="Remove build output">
<delete dir="${build}"/>
</target>
<target name="init">
<mkdir dir="${build.classes}"/>
<mkdir dir="${build.dist}/libs"/>
</target>
<target name="compile" depends="init" description="Compile sources">
<javac srcdir="${src}" destdir="${build.classes}" classpathref="classpath"
release="21" encoding="UTF-8" debug="true" includeantruntime="false"/>
</target>
<target name="jar" depends="compile">
<jar destfile="${build.dist}/libs/gameserver.jar" basedir="${build.classes}"/>
</target>
<target name="dist" depends="jar" description="Build the server into build/dist">
<copy todir="${build.dist}/libs">
<fileset dir="${lib}" includes="*.jar"/>
</copy>
<copy todir="${build.dist}">
<fileset dir="dist"/>
</copy>
<zip destfile="${build}/gameserver.zip" basedir="${build.dist}"/>
</target>
</project>project default="dist": the target that runs when you type ant without arguments;property: variables holding paths, referenced as ${build};path id="classpath": the libraries from lib/ needed for compilation;depends: target dependencies; dist calls jar, jar calls compile, compile calls init;javac: release is the Java version the code is compiled for, encoding is the source encoding, includeantruntime="false" keeps the libraries of Ant itself out of the classpath;jar, copy, zip: packaging the code and assembling the distribution from the libraries and the dist folder with configs and startup scripts.| Message | Cause and fix |
|---|---|
'ant' is not recognized as an internal or external command | %ANT_HOME%\bin is not in Path, or the terminal was opened before the variables were changed |
Unable to find a javac compiler, Perhaps JAVA_HOME does not point to the JDK | JAVA_HOME points to a JRE or to the bin folder; set it to the JDK root folder |
unmappable character (0xC2) for encoding UTF-8, garbled strings | the sources are in windows-1251 but the compiler reads them as UTF-8 (the default since JDK 18). Set encoding="windows-1251" on javac or convert the files to UTF-8 |
package ... does not exist, cannot find symbol | a library is missing from lib/, or the core the datapack depends on has not been built |
release version 21 not supported, invalid target release | the JDK is older than the project requires; check java -version and JAVA_HOME |
Source option 7 is no longer supported. Use 8 or later. | an old build.xml with source/target 1.6 or 1.7: raise them to 8 or higher or replace them with the release attribute. Very old code may need fixes or JDK 8 |
class file has wrong version 65.0, should be 61.0 | a library was built for Java 21 (65) but you are building on Java 17 (61): use JDK 21 |
Target "dist" does not exist in the project | there is no such target; list the targets with ant -p |
java.lang.OutOfMemoryError during compilation | give it more memory: set ANT_OPTS=-Xmx1g or the fork="true" memorymaximumsize="1g" attributes on javac |
A BUILD FAILED message always includes the path to build.xml and a line number. Start with the first compiler error printed above it.
New projects usually use Maven (a pom.xml file, see the Maven guide) or Gradle (build.gradle or build.gradle.kts). Both download dependencies automatically, so libraries do not have to be stored in a lib/ folder. A Gradle project builds with its bundled wrapper, no installation required: gradlew build on Windows or ./gradlew build on Linux, with the output in build/libs/. There is no need to migrate a working ANT build: if it builds reliably, Ant is still a perfectly good choice.
Need a pack that is ready to build, or a complete project set up for you? See our server packs and turnkey projects.
Published 15 October 2026
We help with the server pack, setup, protection and launch — one-off or on an ongoing basis.
Get L2‑Scripts news by email
And 5% off all studio services while you stay subscribed.
The discount is valid while you are subscribed: when ordering, tell the manager your subscription address on Telegram.
Search
News