Font size

Java in AnyLogic

It would be nice if any simulation model could be put together graphically, in drag and drop manner. In practice, however, only very simple models are created using a mouse and not touching the keyboard. As you try to better reflect the real world in the model, you inevitably realize the need to use probability distributions, evaluate expressions and test conditions containing properties of different objects, define custom data structures and design the corresponding algorithms. These things are better done in text, not in graphics, and therefore any simulation modeling tool includes a textual scripting language.

From the very beginning we did not want to invent a proprietary scripting language for AnyLogic. Moreover, the creation of AnyLogic was much inspired by Java, which we think is the ideal language for modelers. On one hand Java is sufficiently high level language where you do not need to care about memory allocation, distinguish between objects and references, etc. On the other hand Java is fully powerful object oriented programming language with high performance. In Java you can define and manipulate data structures of any desired complexity, develop efficient algorithms, use numerous packages available from Sun™/Oracle™ and other vendors. Java is supported by the industry leaders and as Java gets better AnyLogic modelers automatically benefit from it.

A model developed in AnyLogic is fully mapped into Java code and, having been linked with AnyLogic simulation engine (also written in Java), and, optionally, with a Java optimizer, becomes a completely independent standalone Java application. This makes AnyLogic models cross-platform: they can run on any Java-enabled environment.

A frequently asked question is "How much Java do I need to know to be successful with AnyLogic?" Good news is that you do not need to learn object-oriented programming. The "backbone Java class structure" of the model is automatically generated by AnyLogic. In a typical model Java code is present in small portions written in various properties of the graphically created model objects. This can be an expression, a function call, a couple of statements. Therefore you need to get familiar with the fundamental data types, learn the basics of Java syntax, and understand that to do something with a model object you need to call its function.

This section of AnyLogic Help is by no means a complete description of Java language, this is not even an introduction into Java suitable for programmers. This is a collection of information that will allow you to manipulate data and model objects in AnyLogic models. It is sufficient for a typical modeler. For those who plan to write sophisticated Java code, use object-orientedness, work with external Java packages, we recommend to learn Java with a good textbook, for example, one of those ones:

Bruce Eckel. "Thinking in Java", available online here.

"Head First Java. Your Brain on Java - A Learner's Guide" By Bert Bates, Kathy Sierra. Publisher: O'Reilly Media.

For details on Java classes, see Java SDK documentation available at

How can we improve this article?