MIMIC Java API Guide

  1. Table of Contents
  2. Requirements
  3. The MIMIC Java API requires the use of the Java(TM) JDK 7, OpenJDK 11, or newer. We have tested up to Java 18 on both Linux and Windows.

    You should know the basics of compiling and running Java programs on your OS platform (Linux or Windows).

  4. Class Reference
  5. Click here for the generated reference documentation.

  6. Hello, World!
  7. The simplest Hello, World! program for the Java API is with this source code in a file Hello.java in the java/ folder under your MIMIC installation (eg. copy/paste the following text into the file):

    import Mimic.Agent;
    import Mimic.Client;
    import Mimic.ErrorInfo;
    import Mimic.Session;
    public class Hello {
    		String[] args
    		String host = "";
    		int port = 9797;
    		try {
    			Client client = new Client();
    			System.out.println("Opening session " + host  + ":" + port);
    			Session session = client.open_session( host, port );
    			System.out.println("Unloading current agent config file");
    			System.out.println("Loading agent.cfg");
    			System.out.println("Starting agent 1");
    			Agent agent = session.get_agent(1);
    			System.out.println("Closing session");
    		} catch (InterruptedException | ErrorInfo e) {

    then compile it with the Java compiler, eg.

    % javac -classpath . Hello.java

    then run it, eg.

    % java -cp . Hello
    Opening session
    Unloading current agent config file
    Loading agent.cfg
    Starting agent 1
    Closing session

    While you are doing this, notice how your MIMICview reacts to each command - it synchronizes with the simulator to keep up with the latest state. When the first agent turns green, it has synchronized to your state. You have seen that you can control MIMIC from any number of clients using the MIMIC API.

  8. Examples
    • If you prefer, you can create a .jar that contains all the .class files of the API with

      jar cf MIMIC.jar Mimic/*class Utils/*class

    • The TestApp.java file contains a sample test program which exercises all the classes of the MIMIC Java API.

      To compile:

      cd java/test
      javac -classpath .. TestApp.java

      To run (assuming MIMIC is running on this machine):

      java -classpath .:..:../juds/juds-0.9.jar TestApp

      NOTE: if you want to pass environment variables into a Java application, you have to explicitly specify them with the -D command line option to the Java virtual machine, eg.

      java -classpath .:..:../juds/juds-0.9.jar -DMIMIC_PRIV_DIR=some-path TestApp
    • The MimicApplet.html web page contains invocation of a simple applet, that uses the MIMIC Java API to display information about MIMIC running on a system that you can specify. ( NOTE: If you are connecting to a remote system, you will need to modify your security policy as detailed below. )

      Point your browser to load this .html file. The browser will let you load the needed plug-in. This has been tested with both Netscape 4.7x and Internet Explorer 5.x on all supported platforms.

      If you are using the applet to monitor remote systems, A change needs to be made in a file called java.policy for the Java Runtime Engine (JRE) which is being used by the browser. The JRE is the plugin that is downloaded for Java1.2 if not already installed. On Windows, the default location is

      c:\Program Files\JavaSoft\Jre\lib\security\

      Add a line to allow a connection to the MIMIC port:

          permission java.net.SocketPermission "*:9797", "connect";

    • The Script Generator will generate Java code from MIMICView dialogs.