Setting Up Your Development Environment
This article demonstrates how to set up your Java classpath and development environment to run the sample code and create your own MIF applications. We'll use Eclipse as an example IDE and also explain briefly how to set up your classpath if you are not using an IDE.
Prerequisites
- Familiarity with Eclipse or running Java from the command line
- Please ensure that the MIF path contains no spaces (i.e., the path should not contain “documents and settings”, “program files”, etc.)
IDE Users
Eclipse
- Install the MIF plugin using instructions found in install_mif
- See Using the plugin
Other IDE
- Create a new Java project
- Create a source directory for configuration files called config and a source directory for source files called src. NOTE: the config directory should be the first item in the classpath.
- Add the jars in MIF_HOME/mif-*current version*-all.jar to the project's classpath
- Import MIF_HOME/sources/mif-samples into the project
Command Line Users
The directory MIF_HOME/bin contains OS-specific scripts for launching MIF from the command line. These scripts reference the MIF classpath and have a place for you to add classpath entries specific to your application.
- NOTE: If you want to create your own launcher script, please note that MIF's classpath is stored in mif-installer-VERS.jar/META-INF. Therefore, specifying this jar in your classpath includes all MIF dependency jars from MIF_HOME/jars
Windows
In bin/run-mif.bat, edit the variable app_classpath to include the classpath for your application code. Then, run your application with the command:
> bin/run-mif.bat -c com.foo.bar.ClassName
Linux / MacOSX
Before you start: In bin/mif-env.sh, edit the variable $APP_CLASPATH to include the classpath for your application code.
There are two ways to run MIF in Linux/Mac OSX - in the foreground and in the background.
Running MIF in the foreground means logging output goes to your current console and MIF is stopped with ctrl+c. An example of a command to run MIF in the foreground would be:
# bin /mif.sh -c gov.pnnl.mif.samples.hello.stdio.HelloStdioDriver
This command allows us to run the HelloStdioDriver (Hello World) in the foreground and log the activity of the program.
Running Mif in the background means that the program runs as a service and logging goes into a log file in log/. The above example would be as follows:
# bin /mif-server.sh -c gov.pnnl.mif.samples.hello.stdio.HelloStdioDriver
Please note that arguments inputted into the console will be passed to the class through the Java class RunMif. Also note that to successfully run a program, it must have a main method that creates and configures a MIF pipeline as in HelloStdioDriver (Please review the Hello World example if you are unsure which programs create and configure MIF pipelines.