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.

    Download and install OpenJDK 11 from https://jdk.java.net/archive/
    Unzip in C:\Program Files\Java
    Add C:\Program Files\Java\jdk-11.0.2\bin to PATH
    Open Start Search (Windows button)
    Type env and choose "Edit the system environment variables"
    Click "Environment Variables…"
    In "System Variables" find "Path" and click "Edit…"
    In "Edit environment variable" click "New" and paste the path
    Close all dialogs with "OK"
    Create a new environment variable JAVA_HOME as C:\Program Files\Java\jdk-11.0.2\
    To test run java -version on cmd.
    We recommend OpenJDK due to licencing changes from Oracle.
    We use OpenJDK 11 since it is the lastest stable LTS.
  • Install Git

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

    Download and install Git from here.
    During installation you may choose Notepad++ as default editor.
    We recommend getting the source code directly from our public repositories.
  • Install Maven

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

    Download Apache Maven from https://maven.apache.org/download.cgi
    Unzip in C:\Program Files\Apache\Maven
    Add C:\Program Files\Apache\Maven\bin to PATH
    Create a new environment variable M2_HOME as C:\Program Files\Apache\Maven
    To test run mvn --version on cmd.
  • Install the Database Server

    Get latest version from here.

    Download and install MariaDB from https://downloads.mariadb.org/
    We recommend (optionally) downloading and installing HeidiSQL or DBeaver.
    Run in MySQL Client (MariaDB (x64))
    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.

    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.

    On cmd go to C:\opt\l2j\git\l2j-server-login and run mvn install.
    On cmd go to C:\opt\l2j\git\l2j-server-game and run mvn install.
    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.

    Create C:\opt\l2j\server\login
    Unzip C:\opt\l2j\git\l2j-server-login\target\l2jlogin.zip in C:\opt\l2j\server\login
    Create C:\opt\l2j\server\game
    Unzip C:\opt\l2j\git\l2j-server-game\target\l2j-server-game-2.6.1.0-SNAPSHOT.zip in C:\opt\l2j\server\game
    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.

    Create C:\opt\l2j/cli
    Download https://github.com/L2J/l2j-server-cli/releases/download/1.0.0-alpha1/l2jcli-1.0.0.zip
    Unzip l2jcli-1.0.0.zip
    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).

    Run l2jcli.bat
    > account create -u Zoey76 -p -a 8
    > quit
  • Start the Server

    To start the server you need to run two scripts.

    Run C:\opt\l2j\server\login\startLoginServer.bat
    Run C:\opt\l2j\server\game\startGameServer.bat
  • Open Server Ports

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

    Follow the guide here 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.