Introduction
The mosjvm module allows you to create a Java virtual machine within the same process running Mosel, and call static Java methods from within a Mosel model. For example:
javaReturnString := jvmcallstr('com.fico.testpackage.TestClass.myTestFunction', functionArg1, functionArg2, functionArg3) writeln("2+5=", jvmcallint('com.fico.testpackage.SimpleMathOperations.addTwoValues', 2, 5))
In this way, you can interact with pre-existing Java libraries from your Mosel model. However, please note that there are some drawbacks to instantiating a Java virtual machine in the same process as the Mosel virtual machine, and developers are advised to consider other approaches (for example: deploying your Java classes to a Tomcat webserver and interacting with them using standard webservice requests) before building a solution based upon mosjvm.
The developer is advised to read the later chapter which goes into some detail about the limitations of this module. But the most major limitations to be aware of are:
- This module is only available for Windows and Linux.
- This module can not be used within the FICO Analytic Cloud.
- Java 7 or Java 8 must be installed on the machine running the model. Other versions of Java are not supported at this time.
- This module can only run compiled Java .class files (either directly as files or built into a .jar). Java source code must be compiled by other tools.