Exporting models to Java application

AnyLogic Professional allows to export your models as standalone Java applications. This provides users with ability to run AnyLogic models standalone without AnyLogic being installed on their machines.

Java applications can communicate with databases, external files and other applications. This feature enables you to embed simulation models into larger decision support systems.

To export a model as Java application

  1. Select any item of the model in the Projects view and choose Export >To standalone Java application from the main menu, or
    Right-click (Mac OS: Ctrl click) the model in the Projects view (the top-level item of the model tree) and choose Export >To standalone Java application from the popup menu.
  2. This opens the Export Model dialog box.


  3. Select the experiment, which settings you want to be applied to the model, from the Experiment to Export drop-down list.
  4. Specify a folder, where you want files of exported model to be stored, in the Destination folder box. You can browse for the destination folder using the Browse button.
  5. By default, toolbar buttons and other UI elements of your standalone application will be named according to the locale settings of your computer. If you, however, plan to share your application with customers from other countries, choose other language from the Language drop-down list).
  6. If you want to browse to the exported model folder on export completion, leave the check box Browse exported model folder selected.
  7. If you plan to run this standalone model under other operating systems (e.g. distribute your model to other users who might potentially use other OSes), you should provide the model with macOS and Linux versions of the browser which will be used to show the standalone model's animation. To download the pack of the Chromium browser, containing browser versions for Windows, macOS, and Linux, click the For multiple operating systems support... link. This will start the download process. The browsers will be downloaded to the standalone model's folder, and this will make the standalone model completely cross-platform.
  8. Click Finish. You will see a message box informing you that the model was successfully exported.
The model exported as Java application consists of the following files:
Simulation Application (AnyLogic model exported as standalone Java application) does not require AnyLogic installed on the computer and can be run on any Java-enabled machine (computer with Java Standard Edition 9.0 or later installed (download the latest version from the Oracle or Open JDK website)).

To run Simulation Application (AnyLogic model exported as standalone Java application)

  1. Launch the <model name>_<os name>.bat/.cmd/.sh file generated for the exported model. The file might be located in the folder you have specified while exporting the model.

Having run the application, you will see the model window. The model exported as standalone Java application is executed by runtime version of the AnyLogic simulation engine - AnyLogic Engine Runtime. With the help of the About program dialog box you can know the version of the AnyLogic Engine Runtime used by the model as well as the Java version and architecture (32- or 64-bit) and also get access to the license agreement.

The size of the window is defined in the properties of the exported model, in AnyLogic IDE.

If the exported model contains data from the built-in database, make sure to allocate enough memory both for the model and the DB server in the Maximum available memory property of the specified experiment before you begin the export process.

Settings of a standalone model application

AnyLogic allows to tune settings of the model exported as a standalone Java application.

You can do it by creating a textual .ini file named com.anylogic.engine.ini and saving it into the exported model's folder.

Into the file you specify values for the model settings you need to tune. The list of the customizable settings is given in the table below.

The file contents example:

flowchartCountersVisible = false

languageId = es

Setting

Description

Possible values

flowchartCountersVisible

This setting defines whether the counters near the process flowchart blocks (showing the numbers of agents who passed through block ports, etc.) should be displayed or not.

true, false

flowchartPortStateAnimated

Defines whether the "block busy" and "agent available" indicators should be shown near ports of flowchart blocks.

true, false.

useProxy

Defines whether the proxy should be used for network connection.

true, false.

proxy

The proxy address.

URL of the proxy host.

proxyPort

The proxy port.

Positive integer number.

proxyLogin

Proxy login.


proxyPassword

Proxy password.


proxyBypassAddresses

Use this setting to specify the hosts that should be accessed without the proxy.

If you use a proxy to access network (e.g. a GIS map server), but you also need to bypass a proxy to connect to a local server (e.g. a database server), you can specify the local server name in this setting.

By default, all loopback addresses are bypassed.

A list of hosts, separated by the '|' character. Additionally, the wildcard '*' can be used.

parallelWorkersCount

Number of processors (cores) to be used for parallel execution of model runs by experiments with several iterations (e.g. parameter variation, optimization) and also by some libraries (e.g. Pedestrian Library).

Positive integer number.

standaloneBrowserPath

Path to the browser's executable file. Use this setting in case you need to use not Chromium but some other browser to run the standalone model.

The path should not contain single '\' characters, '/' are preferred instead.

standaloneBrowserCommandArguments

Command arguments for custom browser.

Use $1 to refer to the URL of the running model server.

standaloneServerPort

The port where the server with the running model will start on. This port will be used to run the model in the browser, e.g. setting the port 12345 you make the model run at http://localhost:12345.

Positive integer number not greater than 65535.

Some port values might be reserved by the Operating System or some services, especially values less than 1024.

languageId

By default the application UI will be in the language that was selected on model export. Here you can change it to any other language from the set of languages supported by AnyLogic: English, Russian, German, Chinese, Spanish, or Portuguese (Brasil).

One of text constants:

en - English

es - Spanish

pt_BR - Portuguese (Brasil)

zh - simplified Chinese

ru - Russian

de - German

Exporting a standalone application from command line

AnyLogic command line interface supports export of a model (or several models at once) as standalone Java application.

Before calling the export command, use the cd command to change the working directory to the AnyLogic folder on your computer (specify absolute path), e.g.: cd C:\Program Files\AnyLogic 8.5 Professional.

The command syntax is as follows:

anylogic -e "absolute path to the exported model .alp file"

For example:

anylogic -e "D:\My Models\Call Center\Call Center.alp"

Here, -e is a common flag to run silent export. After it you can list the paths to as many models for export as you need. The models will be loaded, built, exported, and closed one by one in the order of listing. For each model, all its experiments will be exported. By default each experiment will exported to a new folder <model name>_<experiment name> which will be created automatically in the model's parent folder. You can also export the model to an specific folder by specifying parameter -o "folder path" in the command line.

anylogic -e -o "absolute path to the destination folder" "absolute path to the exported model .alp file"

For example:

anylogic -e -o "C:\Export\Standalone Model Applications" "D:\My Models\Call Center\Call Center.alp"

If the model only contains a default simulation experiment, the following folder will appear in the model's parent folder: Call Center_Simulation.

Exporting specific experiments

To export a particular experiment of the model, specify the experiment's name after the model's name in the command. You can list more than one experiment separated by comma.

anylogic -e "D:\My Models\Call Center\Call Center.alp:Simulation,OptimizedSimulation"

Upon calling this command, the following two folders will appear in the model's parent folder: Call Center_Simulation and Call Center_OptimizedSimulation.

Depending on whether AnyLogic is running or not, the export process will differ.

When AnyLogic is not running:

When AnyLogic is running:

Dependent model support

If the exported model has another model (or several) in its list of dependencies, these models will be exported automatically.

The search for the dependencies is executed by the java package name. It starts from the exported model folder and its subfolders and then moves upwards the folder structure.

If any of the folders contains more than one .alp file that satisfies the search conditions, neither of these models will be exported. The export process will run its course, but an error message will be logged.

Opening a model from command line

Before calling the command to open a model, use the cd command to change the working directory to the AnyLogic folder on your computer (specify absolute path), e.g.: cd C:\Program Files\AnyLogic 8.5 Professional

The command syntax is as follows:

anylogic "absolute path to the model .alp file"

For example:

anylogic "D:\My Models\Call Center\Call Center.alp"

You can list the paths to as many models as you need separated by space character. The models will be opened all at once.

Alternatively, you can open models without changing the working directory to the AnyLogic folder on you computer. In this case, omit the anylogic command and specify the absolute path to the AnyLogic executable file AnyLogic.exe.

For example:

"C:\Program Files\AnyLogic 8.5 Professional\AnyLogic.exe" "D:\My Models\Call Center\Call Center.alp"

Running a specific experiment from command line

To run a particular experiment of the model, use the -r flag and specify the experiment's name after the path to the model in the command. You can list only one experiment. The path to the model and the experiment's name must be separately enclosed by quotation marks each and separated by space character.

The command syntax is as follows:

anylogic -r "absolute path to the model .alp file" "name of the experiment"

For example:

anylogic -r "D:\My Models\Call Center\Call Center.alp" "Simulation"