Starting Java
The first time a jvmcall<type> function is called from a model in a Mosel process, mosjvm will load and initialize a Java virtual machine. This Java virtual machine will then be used by all subsequent jvmcall<type> functions called by models in this process—if your Java functions modify any static fields, those modified values will be read by subsequent calls, possibly from different models. If you are using mosjvm from multiple submodels within the same Mosel instance, your Java code will need to be threadsafe.
By default, mosjvm will look for the Java Runtime Environment in the following locations:
- The folder specified by the MOSJVM_JAVA_HOME environment variable, if set
- The folder specified by the JAVA_HOME environment variable, if set
- Relative to the location of a java executable found in a folder on the PATH environment variable
- In some common install locations
To force mosjvm to use a specific installation of Java, set the environment variable MOSJVM_JAVA_HOME before starting Mosel.