L2J Server on Windows 10

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.

  1. Go to AdoptOpenJDK and download Java JDK 14 MSI package.
  2. Download the .msi file. Open it to launch the installation program.
  3. Read and accept the license if you are happy with the terms.
  4. On the Custom Setup screen you can choose the features that you want to install and optionally change the default installation directory.

Install Git

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

  1. Download and install Git from https://git-scm.com/download/win.
  2. During installation you may choose Notepad++ as default editor.

Install the Database Server

Download an install a database server and create a specific user.

  1. Download and install MariaDB from https://downloads.mariadb.org/
  2. Run MySQL Client (MariaDB (x64))
  3. Execute the following SQL statements to create a L2J specific database user:
CREATE OR REPLACE USER 'l2j'@'%' IDENTIFIED BY 'l2jserver2019';
GRANT ALL PRIVILEGES ON *.* TO 'l2j'@'%' IDENTIFIED BY 'l2jserver2019';
FLUSH PRIVILEGES;

Get the Source Code

Our official repositories are the ones listed bellow.

  1. Create a folder C:\opt\l2j\git and open cmd and run the following commands:
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

We use Maven to build the server files.

cd C:\opt\l2j\git\l2j-server-login
mvnw install
cd C:\opt\l2j\git\l2j-server-game
mvnw install
cd C:\opt\l2j\git\l2j-server-datapack
mvnw install

Deploy the Server

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

  1. Create C:\opt\l2j\server\login
  2. Unzip C:\opt\l2j\git\l2j-server-login\target\l2jlogin.zip in C:\opt\l2j\server\login
  3. Create C:\opt\l2j\server\game
  4. Unzip C:\opt\l2j\git\l2j-server-game\target\l2j-server-game-2.6.2.0-SNAPSHOT.zip in C:\opt\l2j\server\game
  5. Unzip C:\opt\l2j\git\l2j-server-datapack\target\l2j-server-datapack-2.6.2.0-SNAPSHOT.zip in C:\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.

  1. Create C:\opt\l2j/cli
  2. Unzip the file in C:\opt\l2j\cli
  3. Run l2jcli.bat
db install -sql C:\opt\l2j\server\login\sql -u l2j -p l2jserver2019 -m FULL -t LOGIN -c -mods
db install -sql C:\opt\l2j\server\game\sql -u l2j -p l2jserver2019 -m FULL -t GAME -c -mods
quit

Create Administrator Account

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

  1. Run l2jcli.bat
account create -u Zoey76 -p -a 8
quit

Start the Server

To start the server you need to run two scripts.

  1. Run C:\opt\l2j\server\login\startLoginServer.bat
  2. Run C:\opt\l2j\server\game\startGameServer.bat

Open Server Ports

If you are not playing from localhost you may need to open the some ports on your server.

  1. Follow the guide Tom's Hardware and open ports 2106 and 7777.

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:

127.0.0.1 l2authd.lineage2.com

BAT file

Create a .bat file with the following content:

@start l2.bin IP=127.0.0.1

Custom exe

Here is a C++ Win32 exe example:

#define _WIN32_WINNT _WIN32_WINNT_WINXP
#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=127.0.0.1", 0, SW_HIDE);
}

Download compiled version from here.

More information here.