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. Download and install OpenJDK 11 from https://jdk.java.net/archive/
  2. Unzip in C:\Program Files\Java
  3. Add C:\Program Files\Java\jdk-11.0.2\bin to PATH
  4. Open Start Search (Windows button)
  5. Type env and choose "Edit the system environment variables"
  6. Click "Environment Variables..."
  7. In "System Variables" find "Path" and click "Edit..."
  8. In "Edit environment variable" click "New" and paste the path
  9. Close all dialogs with "OK"
  10. Create a new environment variable JAVA_HOME as C:\Program Files\Java\jdk-11.0.2\
  11. To test run java -version on cmd.

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 Maven

L2J uses Maven to build the components from the source code.

  1. Download Apache Maven from https://maven.apache.org/download.cgi
  2. Unzip in C:\Program Files\Apache\Maven
  3. Add C:\Program Files\Apache\Maven\bin to PATH
  4. Create a new environment variable M2_HOME as C:\Program Files\Apache\Maven
  5. To test run mvn --version on cmd.

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. Exceute the following SQL statements to create a L2J specific database user:
CREATE OR REPLACE USER 'l2j'@'%' IDENTIFIED BY 'l2jserver2019';
GRANT USAGE ON *.* TO 'l2j'@'%' IDENTIFIED BY 'l2jserver2019';
FLUSH PRIVILEGES;

Get the Source Code

Our official repositores 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.

  1. On cmd go to C:\opt\l2j\git\l2j-server-login and run mvn install.
  2. On cmd go to C:\opt\l2j\git\l2j-server-game and run mvn install.
  3. On cmd go to C:\opt\l2j\git\l2j-server-datapack and run mvn 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.1.0-SNAPSHOT.zip in C:\opt\l2j\server\game
  5. Unzip C:\opt\l2j\git\l2j-server-datapack\target\l2j-server-datapack-2.6.1.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. Download https://github.com/L2J/l2j-server-cli/releases/download/1.0.0-alpha1/l2jcli-1.0.0.zip
  3. Unzip l2jcli-1.0.0.zip in C:\opt\l2j\cli
  4. Run l2jcli.bat
> db install -l C:\opt\l2j\server\login\sql -u l2j -pw l2jserver2019 -m FULL -t LOGIN
> db install -l C:\opt\l2j\server\game\sql -u l2j -pw l2jserver2019 -m FULL -t GAME
> 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 hInst, HINSTANCE prevInst, LPWSTR szCmdLine, int nCmdShow)
{
	ShellExecute(0, L"open", L"cmd.exe", L"/C start l2.bin IP=127.0.0.1", 0, SW_HIDE);
}

More information here.