# Writing plugins for Micro-Manager

This documentation is for the current version of Micro-Manager (2.0). For Micro-Manager 1.4 plugins, please see Writing plugins for Micro-Manager-1.4.

## Getting started

Micro-Manager 2.0 uses SciJava’s plugin discovery mechanism. This uses Java annotations that need to be generated by your build environment. Currently, we have no idea how to do that from an IDE, but you can still use your IDE (such as Eclipse, NetBeans or IntelliJ) to edit and compile your code. The following instructions (based on work by SophieH) will help you build plugins that can run in Micro-Manager 2.0. When you figure out how to do this completely within an IDE, please contribute your notes!

## Obtain the Micro-Manager source code

Clone the Micro-Manager github repository. Optionally run the command git submodule update --init --recursive which will clone all submodules (currently the Core and devices, which you will not need to build a Java plugin).

## Install a Java JDK and Apache ant

You will need to set the following environment variables. On Windows, they can be added in Control Panel > System and Security > System > “Advanced system settings” > “Environment variables…”.

• JAVA_HOME: set to the path to your JDK installation, e.g. C:\Program Files\AdoptOpenJDK\jdk8u181-b13. Do not add quotes to the value, even if it contains spaces.
• ANT_HOME: set to the path to your Ant installation (whereever you placed the extracted binary package), e.g. C:\apache-ant-1.9.16. Do not add quotes to the value, even if it contains spaces.
• PATH: It is convenient to add Ant to the command search path. You can append ;%ANT_HOME%\bin to the end of the System PATH varialbe, or add a User variable named PATH and set its value to %PATH%;%ANT_HOME%\bin.

Verify that the Environment Variables were set correctly and Ant is working properly by typing ant -version. You should get a reply similar to: Apache Ant(TM) version 1.9.16 compiled on July 10 2021

In your terminal application (I use Git bash), cd to the root of the micro-manager source code and ran the two following commands:

ant -f buildscripts/fetchdeps.xml
ant build-buildtools


## Copy files from binary installation of Micro-Manager

If you had not yet done so, download and install a recent version of Micro-Manager. Copy the following .jar files from that Micro-Manger installation into the build\Java folder:

MMJ_.jar
AcqEngJ-0.12.3.jar
MMCoreJ.jar


Plugin source code is in the plugins directory. Plugin code that should be accessible from other plugins is in the libraries directory. If you intent to create a new plugin, have a look at the Example plugin (you may want to test building and running the Example plugin). Either edit the source code of an existing plugin, or create a new one yourself.

## Build and run your plugin code

Change directory to micro-manager\plugins\Example, and issue the command ant jar. This should result in a file Example.jar in the build\Java\plugins directory. Copy this jar fiel to the mmplugins folder of your Micro-Manager installation and it should appear in the menu and work.