L2J Server on Debian

L2J is a complex piece of software engineering, it's divided in three main components, login server, game server and datapack.

Install OpenJDK

L2J is built using Java SE, to build you need Java JDK as well.

Install Git

L2J uses Git as version control system on BitBucket, use it to get the latest versions.

apt-get install git
We recommend getting the source code directly from our public repositories.

Install the Database Server

Get latest version from here.

Create MariaDB.list file and add the following content:

vi /etc/apt/sources.list.d/MariaDB.list
# MariaDB 10.4 repository list - created 2019-08-12 01:57 UTC
# http://downloads.mariadb.org/mariadb/repositories/
deb [arch=amd64] http://mirror.hosting90.cz/mariadb/repo/10.4/debian buster main
deb-src http://mirror.hosting90.cz/mariadb/repo/10.4/debian buster main
apt update
apt install mariadb-server
mariadb -u root -p
MariaDB > CREATE OR REPLACE USER 'l2j'@'%' IDENTIFIED BY 'l2jserver2019';
MariaDB > GRANT ALL PRIVILEGES ON *.* TO 'l2j'@'%' IDENTIFIED BY 'l2jserver2019';

Get the Source Code

Our official repositories are the ones listed bellow.

mkdir -p /opt/l2j/git && cd /opt/l2j/git
git clone https://bitbucket.org/l2jserver/l2j-server-login.git
git clone https://bitbucket.org/l2jserver/l2j-server-game.git
git clone https://bitbucket.org/l2jserver/l2j-server-datapack.git

Build the Server from Source Code

Our official repositories are the ones listed bellow.

cd /opt/l2j/git/l2j-server-login && chmod 755 mvnw && ./mvnw install
cd /opt/l2j/git/l2j-server-game && chmod 755 mvnw && ./mvnw install
cd /opt/l2j/git/l2j-server-datapack && chmod 755 mvnw && ./mvnw install

Deploy the Server

The deployment process at the moment is simply unzipping the built files.

mkdir -p /opt/l2j/server/login
unzip /opt/l2j/git/l2j-server-login/target/l2jlogin-*.zip -d /opt/l2j/server/login
mkdir -p /opt/l2j/server/game
unzip /opt/l2j/git/l2j-server-game/target/l2j-server-game-*.zip -d /opt/l2j/server/game
unzip /opt/l2j/git/l2j-server-datapack/target/l2j-server-datapack-*.zip -d /opt/l2j/server/game

Get L2J CLI and Install the Database

L2J CLI is a tool developed by Zoey76 that allows us to implement automated deployments and initial configurations.

Initial Configuration

You need to give certain permissions for the server to run properly.

cd /opt/l2j/server/login && mkdir -p log
chmod 755 LoginServer_loop.sh
chmod 755 startLoginServer.sh
chmod 755 startSQLAccountManager.sh
cd /opt/l2j/server/game && mkdir -p log
chmod 755 GameServer_loop.sh
chmod 755 startGameServer.sh

Create Administrator Account

Use the L2J CLI to create an administrator account, 8 is the maximum account level (master).

cd /opt/l2j/cli
account create -u Zoey76 -p -a 8

Start the Server

To start the server you need to run two scripts.

cd /opt/l2j/server/login
cd /opt/l2j/server/game

Open Server Ports

If you are not playing from localhost you may need to open the following ports.

ufw allow 2106/tcp
ufw allow 7777/tcp

Connect to the Server

In order to connect to the server you have the following options:

HOSTS file

Edit C:\Windows\System32\drivers\etc\hosts and add this line: l2authd.lineage2.com

BAT file

Create a .bat file with the following content:

@start l2.bin IP=

Custom exe

Here is a C++ Win32 exe example:

#define NOMINMAX
#include <windows.h>
#include <cstdlib>

// Start L2 as .bin with IP as parameter.
// You can use IP or DNS as IP parameter.
// You could include other parameters.
// You can change the path to the .bin file to avoid including the L2.exe inside the System folder.
// Author: Zoey76
int _stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) {
	ShellExecute(0, L"open", L"cmd.exe", L"/C start l2.bin IP=", 0, SW_HIDE);

Download compiled version from here.

More information here.