There are several ways to simulate Modelica models from a Java program. To directly simulate the Modelica code, use the Java interface of an existing Modelica simulator:
- OpenModelica's Java interface
- Java interface for Dymola
Another option is to export the Modelica code to a Functional Mockup Unit (FMU) via the Functional Mockup Interface (FMI), e.g. using Dymola. Then use a Java FMI library (e.g. JFMI) to interact with the FMU. Note that you'll probably need to supply the solver code yourself. However this is far easier for an FMU than for raw Modelica code.
Also see this question on SO for more information about exchaning information between Modelica and Java.