This page includes user manuals for two applications:

  1. LPhy studio - the GUI for LPhy language

  2. LPhyBEAST - a BEAST 2 package that takes a LPhy script and produces a BEAST 2 XML file.

Java 17

LPhy and LPhyBEAST require Java 17. We recommend you install OpenJDK 17.

To check your Java version, use the command line below:

java -version

LPhy Studio

LPhy studio installation

  1. Go to the LPhy release page, and download the latest release, e.g., lphy-studio-1.3.*.zip.

  2. Unzip the compressed file, this will create a folder called lphy-studio-1.3.*.

This is the location of your LPhyStudio install. The lphy-studio-1.3.* path will be your $LPHY_PATH. Its folder structure should look like:

    ├── examples
    │    ├── data
    │    ...
    ├── lib
    │    ...
    │    ├── lphy-1.3.*.jar
    │    ├── lphy-studio-1.3.*.jar
    │    ...
    ├── LICENSE    
    ├── src
    └── tutorials
         ├── data

Example LPhy scripts are in the examples subdirectory, and libraries are in the lib subdirectory.

If you are using LPhyBEAST, we recommend you to copy or move the entire folder with everything under your BEAST 2.* folder, and rename it into lphy. So you can skip the step installing LPhy during the LPhyBEAST installation.

Launching LPhy studio

To run LPhy studio use the commands below:

java -p lib -m lphystudio

(Optional) To use LPhy extensions, copy the extension jar file into the lib folder of your $LPHY_PATH.

To launch LPhy Studio with a script file use

java -p lib -m lphystudio tutorials/RSV2.lphy

Note that you can replace tutorials/RSV2.lphy with the path to another LPhy script file.

Please note: the LPhy studio will set the working directory (also property user.dir) to the parent directory which the script sits inside. For example, in the above command line, the working directory will change to the subfolder tutorials not the folder $LPHY_PATH.

This is to cooperate with any relative paths inside the LPhy script, such as readNexus(file="data/RSV2.nex", ...);, It is comparatively easy to organise all the LPhy scripts in a folder (e.g. tutorials/) and their required alignments (e.g. RSV2.nex) in the subfolder data under the folder.

If you are new to LPhy, we recommend reading this introduction, before you try the tutorials.

LPhyBEAST installation

LPhyBEAST requires BEAST 2.6.7 or higher, and is installable as a BEAST 2 package called lphybeast.

  1. To install LPhyBEAST first start Package Manager by opening BEAUti, and from the menu select File => Manage Packages.
  2. Click on Package repositories to open the “BEAST 2 Package Repository Manager”.
  3. Click the Add URL button, add the URL “”, and click OK.

The packages-extra URL should now appear as shown below

Figure 1: Adding packages-extra URL.
  1. Click the Done button.

  2. Restart Package Manager.

  3. The lphybeast package should now appear in the list of available packages. Select lphybeast from the package list, then use Install/Upgrade to install.

Note: Installation may take few minutes to download and install. Please wait until a confirmation popup appears on the screen.

Figure 2: Confirmation message for successful install of lphybeast.
  1. Restart Package Manager once more. Now lphybeast and dependent packages should appear as “installed”.

Alternatively, you can install it using command line following the instruction.

Install LPhy libraries and download starting script

The package lphybeast does not include LPhy, so we need to install LPhy libraries.

  1. Download the LPhy studio from the release page, such as lphy-studio-1.3.*.zip.

  2. Unzip it under your $BEAST_DIR folder where you installed the BEAST 2.

Figure 3: Set LPHY_LIB path.
  1. Make sure there is only one LPhy folder, such as lphy-studio-1.3.*, inside your $BEAST_DIR.

  2. Download the bash script lphybeast from LPhyBEAST’s repo, and put it into the bin folder under $BEAST_DIR with other scripts.

The final folder structure looks like:

    ├── bin
    │    ...
    │    ├── lphybeast
    │    ...
    ├── examples
    ├── lib
    │    ├── beast.jar
    │    ...    
    ├── lphy-studio-1.3.*
    │    ├── examples
    │    ├── lib
    │    │    ...
    │    │    └── lphy-1.3.*.jar
    │    ...
    ├── templates

Eventually, we can start LPhyBEAST using the script lphybeast. It will launch LPhyBEAST through another BEAST 2 application called applauncher, while adding the $LPHY_LIB folder into the classpath.

LPhyBEAST usage

Make sure you have the script lphybeast ready and set LPHY_LIB path properly. Now, we can run the following command line to show the usage.

$BEAST_DIR/bin/lphybeast -h

Then, try to create “RSV2.xml” from the tutorial script “RSV2.lphy”:

cd $LPHY_PATH/tutorials/
$BEAST_DIR/bin/lphybeast RSV2.lphy

Or use the absolute path and work from a different folder:

$BEAST_DIR/bin/lphybeast $LPHY_PATH/tutorials/RSV2.lphy

Create 5 XML for simulations:

$BEAST_DIR/bin/lphybeast -wd $LPHY_PATH/tutorials/ -r 5 RSV2.lphy

Some conventions

  1. If the input/output is a relative path, then concatenate user.dir to the front of the path.

  2. Use -wd to set user.dir. But if -wd is not given, then user.dir will be set to the parent folder where the LPhy script sits inside. For example:

$BEAST_DIR/bin/lphybeast -wd $LPHY_PATH/tutorials/ -l 15000000 -o RSV2long.xml RSV2.lphy

This also contains two extra arguments:

  • -l changes the MCMC chain length (default to 1 million) in the XML;
  • -o replaces the output file name (default to use the same file steam as the lphy input file).

As this LPhy script uses the relative path to load data, D = readNexus(file="data/RSV2.nex", ...);, the data subfolder containing RSV2.nex has to be in the same folder where “RSV2.lphy” sits inside.

Note: please use -wd to simplify your input and output paths. Do not make them more complex, such as combining -wd with relative paths in either input or output. For example, do not try -wd $LPHY_PATH tutorials/RSV2.lphy, then you will mess up some relative paths inside the LPhy scripts, e.g. readNexus.

If something goes wrong …


The most cases are caused by the inconsistent relative path between the input file and the data inside the LPhy script. Please see the subsection “Relative file path”.

SEVERE: Cannot find Nexus file ! .../data/RSV2.nex, user.dir = ...
	at lphy.core.functions.ReadNexus.apply(
	at lphy.graphicalModel.DeterministicFunction.generate(
	at lphy.parser.SimulatorListenerImpl$SimulatorASTVisitor.visitMethodCall(

LPhyBEAST failed by an improper installation

If the LPhy library folder is not in a correct path, you will see the following exceptions:

java.lang.NoClassDefFoundError: lphy/core/LPhyParser
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredMethods(
	at java.base/java.lang.Class.getMethodsRecursive(
	at java.base/java.lang.Class.getMethod0(
	at java.base/java.lang.Class.getMethod(
	at Source)
	at Source)
Caused by: java.lang.ClassNotFoundException: lphy.core.LPhyParser
	at java.base/
	at java.base/java.lang.ClassLoader.loadClass(
	at java.base/java.lang.ClassLoader.loadClass(
	... 13 more

LPhyBEAST failed by Java version

If the lphybeast -h failed with the following error message about Java version:

lphybeast/LPhyBEAST has been compiled by a more recent version 
of the Java Runtime (class file version 61.0), this version of 
the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(

First, check if your local Java is 17 using java -version. If yes, you need to download and use BEAST 2 without JRE, because with JRE, applauncher will be forced to use the provided JRE in BEAST 2 which currently is 1.8.