2. Getting Started (command line)

This section introduces EMMA command line tools. It starts with an example of how to run an application so that coverage instrumentation is performed on-the-fly, as the classes are loaded by the JVM, and then repeats the same process by breaking it into distinct instrumentation/execution/reporting steps.

Sample source code

The source code located in examples/src directory of EMMA distribution is used for all examples in this tutorial.

Section 3, “Getting Started (ANT)” works with the same sample application through Apache ANT build tool. All of EMMA's command-line functionality is available via EMMA's ANT tasks and there is some duplication of content between this and the following sections, so you might want to skip ahead if you expect to obtain coverage through ANT builds exclusively. You should also skip ahead if you've already gone through "Getting Started" steps on EMMA's web site.

2.1. Adding EMMA command line tools to your classpath

The recommended way to install EMMA command.line tools is to make emma.jar an extension library for your Java Runtime Environment (JRE). This is accomplished simply by copying emma.jar to <your jre dir>/lib/ext/ directory for whichever JRE you use from command line.

EMMA distribution neither depends on any external Java libraries nor includes them inside EMMA jars. This means installing EMMA as a JRE extension will not pollute your classpath with unknown versions of Java libraries that you might be using elsewhere in your work. This also has the advantage of setting up emma.jar as a trusted Java library, which is useful for collecting coverage in security sensitive configurations.

Still, if you are wary of adding a third-party library as a standard JRE extension, just make sure that all your EMMA command line invocations add emma.jar to the JVM classpath:

>java -cp .../lib/emma.jar <emma or emmarun command>