Private
Protection
Special Offers
Catalog
Auto donation
Step by step: installing JDK 17/21 and Maven, checking the environment, running mvn clean package, finding the built server and fixing typical build errors.
Maven is used by packs that have a pom.xml file in the root folder. If there is a build.xml instead, the project is built with ANT (see the ANT guide); if there are build.gradle and gradlew, it is a Gradle project and you build it with gradlew build.
| Component | Version | Notes |
|---|---|---|
| JDK | 17 or 21, 64-bit | check pom.xml for the required version: maven.compiler.release or source/target |
| Maven | 3.9 or newer | not needed if the project ships the mvnw wrapper |
| Internet access | for the first build | Maven downloads dependencies into the local repository |
JAVA_HOME pointing to the JDK root folder without \bin, for example C:\Program Files\Java\jdk-21.%JAVA_HOME%\bin as a separate entry to Path (many JDK installers do this for you).java -version and javac -version.apache-maven-3.9.x-bin.zip from the official Apache Maven website.C:\tools\maven.C:\tools\maven\bin to Path.mvn -v. Look at the Java version line: Maven must run on the JDK your pack needs.Sample output:
mvn -v
Apache Maven 3.9.9
Maven home: C:\tools\maven
Java version: 21.0.5, runtime: C:\Program Files\Java\jdk-21mvnw and mvnw.cmd, you do not have to install Maven at all: the wrapper downloads the right version itself. Run mvnw.cmd clean package on Windows or ./mvnw clean package on Linux. On Ubuntu the JDK and Maven come from the standard repositories: sudo apt install openjdk-21-jdk maven.pom.xml is. In File Explorer you can type cmd into the address bar or choose Open in Terminal from the folder's context menu.clean removes the output of the previous build, package compiles the code and packs it into a jar/zip.%USERPROFILE%\.m2\repository and may take several minutes; later builds are faster.BUILD SUCCESS. On failure Maven prints BUILD FAILURE with the cause above it: read the first error, not the last one.cd D:\l2\source
mvn clean package
# skip running the tests
mvn clean package -DskipTests
# build only the gameserver module and the modules it depends on
mvn clean package -pl gameserver -am| Command or option | What it does |
|---|---|
mvn clean | deletes the target/ folder |
mvn compile | compiles the code only |
mvn package | compiles and packs into a jar/zip |
mvn install | the same plus a copy in the local repository; needed when modules depend on each other and are built separately |
-DskipTests | tests are compiled but not run |
-Dmaven.test.skip=true | tests are neither compiled nor run |
-o | offline mode: only dependencies from the local repository |
-U | force a re-check of dependencies in remote repositories |
mvn dependency:tree | prints the dependency tree |
-Dname.with.dots=value in quotes: mvn clean package "-Dmaven.test.skip=true". Otherwise PowerShell splits them at the dot and Maven fails. In cmd no quotes are needed.mvn assembly:assembly. That goal has been removed from current versions of the assembly plugin: if the distribution is configured in pom.xml, the archive is created automatically during the package phase.target/ folder holds the compiled jar (for example, the game server or login server core).*.zip archive or a distribution folder with libraries, configs and startup scripts.target/. The file name is set in pom.xml (finalName and the assembly settings).The default memory settings are usually enough. If a large project fails with OutOfMemoryError, give Maven more memory through the MAVEN_OPTS variable (old guides misspelled it as MAVEN_OPT):
set MAVEN_OPTS=-Xmx2g;$env:MAVEN_OPTS = "-Xmx2g";-Xmx2g in the .mvn/jvm.config file in the project root.clean, then package. The Skip Tests button on the tool window toolbar turns tests off. The JDK used by Maven is set in Settings > Build, Execution, Deployment > Build Tools > Maven > Runner > JRE.clean package in Goals and tick Skip Tests if needed. Pick the right JDK on the JRE tab.More about working with the project in an IDE is in the IntelliJ IDEA, Eclipse and Git guide.
| Message | Cause and fix |
|---|---|
'mvn' is not recognized as an internal or external command | the Maven bin folder is not in Path, or the terminal was opened before the change; open a new window |
The JAVA_HOME environment variable is not defined correctly | JAVA_HOME points to the bin folder, to a JRE or to a path that does not exist; it must be the JDK root folder |
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? | Maven runs on a JRE: install a JDK and fix JAVA_HOME |
release version 21 not supported, invalid target release: 17 | the JDK is older than the project requires; check the Java version line in mvn -v |
Could not resolve dependencies, Could not transfer artifact | no access to the dependency repository (internet, proxy) or the library is not in any public repository; see the next section |
was cached in the local repository, resolution will not be reattempted | a failed download was cached: build with -U or delete that library's folder in .m2\repository |
unmappable character for encoding UTF-8 | the sources are not UTF-8: set their real encoding in the project.build.sourceEncoding property or convert the files to UTF-8 |
OutOfMemoryError: Java heap space | increase MAVEN_OPTS (see above) |
There are test failures | tests failed: fix them or build with -DskipTests |
An offline build (mvn -o) works only if every dependency is already in the local repository. You can download them in advance with mvn dependency:go-offline on a machine with internet access. If the project uses a jar that is not published in any repository, install it into the local repository by hand:
mvn install:install-file -Dfile=lib\some-lib.jar -DgroupId=local.libs -DartifactId=some-lib -Dversion=1.0 -Dpackaging=jarAfter that pom.xml can reference the library with the same groupId, artifactId and version. How to run the built server on Windows is covered in the Windows setup guide. Ready-made packs with source code are in the server packs section.
Published 23 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