Applications created using the Vensim DLL may be provided to others who have installed the Vensim Model Reader. In order to make the resulting application easily usable by others the Vensim Model Reader uses a two step process to open these applications.
First the Vensim Model Reader opens a published package that contains the model or models and the application files that call the Vensim DLL. From this package it extracts those application files necessary to run the application (for example an executable, a Java .jar file or a Microsoft Excel file), it then calls on the operating system to execute that file. During this process the location of the published archive is recorded so that when the Vensim DLL is called on to open an archive it knows exactly where to look for it. This means you do not need to worry about directory location, or even the filename, of the published application package you send to others. When the Vensim DLL is asked to open a package it is redirected to the source package. Subsequent requests to open a package are ignored, and the current package left open. From the User’s perspective they open the packaged application and then are presented with the application you developed.
One consequence of this structure is that all models and supporting files must be in a single published package. Requests to open another package will fail. Similarly, with the Vensim Model Reader installed attempting to start your application directly will fail with a message to open the package using the Model Reader. Using the Vensim Model Reader to develop applications is a violation of the license terms.
A second consequence of this is that if you are using Java to develop applications you will need to create a .jar file for your application. In general, this is the standard anyway. The person using the application will also need to have whatever programs are required to run your application installed.
Opening the packaged application using Vensim DSS will give the same behavior that the Vensim Model Rader does. Vensim will open the packaged application, extract your files, then launch the application. Still, in order to test the performance of an application with the Vensim Model reader you may want to install the Vensim Model Reader on a computer that does not have Vensim DSS installed.
During the development of your application (when it is not launched by Vensim DSS or the Vensim Model Reader) calls you make to open a package can use the full path and file name. Given the two stage process for opening models this location can be anything – there is no need to try to have the user create a similar file structure. One difference in development, however, is that you can use multiple calls to open different packages in development. For final publication all of these materials will need to be put into a single package.
Development Notes
Even though eventually the model and files will be packaged in a .vpa file during development it makes more sense to open a .vpm file. Just use SPECIAL>LOADMODEL|model.vpm. When you combine your application and the files that were in the .vpm file, the filename referred to by model.vpm above will be ignored. Instead the .vpa file containing the application will be used. When this archive is open the first model listed will be used. If your application only requires one model, you don’t need to do anything else. If your application requires multiple models it is probably best to use something like
SPECIAL>LOADMODEL|model.vpm
SPECIAL>LOADMODEL|model.mdl
The first of these opens the published package, the second opens the model from the package. If the model is already open it does not do anything. Use this to make sure you are working with the model you think you are.
Notes on .jar Files
Most Java development environments will automatically create a .jar file for you. However, if you are using a command line interface you will need to do the following:
1. | Put Vensim.class in the directory com/vensim of the directory you are creating the .jar file from. |
2. | Compile all your Java files. |
3. | Create the file yourapp.mf that identifies the main routine. For example VensimApp.mf contains: |
Manifest-Version: 1.0
Created-By: Hand
Main-Class VensimApp
4. | Package everything into a jar file. For example with the command |
Jar –cfvm VensimApp.jar VensimApp.mf *.class com
5. | Publish a .vpa file that specifies VensimApp.jar as the calling application and contains the necessary models and supporting files. |