Developing Apama Applications > Using Apama Studio > Debugging Apama Java Applications > Example debug session > Debug example of preparing code and JAR file
Debug example of preparing code and JAR file
Consider the following sample Java code, which is the basis for an Apama Java application. The files containing the complete code are Simple.java and Tick.java, which are located in the samples\java_monitor\simple\src directory of your Apama installation.
@Application(name = "Simple",
          author = "John Doe",
          version = "1.0",
          company = "Apama",
          description = "sample")
@MonitorType(description = "A simple java monitor")
 
public class Simple implements Monitor, MatchListener {
   public Simple() {}
   public void onLoad() {
      EventExpression eventExpr =
         new EventExpression("all Tick(*, >10.0):t");
      eventExpr.addMatchListener(this);
   }
 
   public void match(MatchEvent event) {
      Tick tick = (Tick)event.getMatchingEvents().get("t");
      tick.emit();
   }
}
Here is the Tick class (Tick.java):
@EventType(description = "Event that signals a stock trade")
public class Tick extends Event {
   public String name;
   public double price;
   public Tick() {
      this("", 0);
   }
 
   public Tick(String name, double price){
      this.name = name;
      this.price = price;
   }
}
Assume that Simple.java is part of your Apama Studio project. Open or create the project in Apama Studio and add the code if necessary. Note that this code is already annotated with the information required for creating the Apama Java JAR manifest.
The next step is to compile and pack the class bytecode into a JAR file, and create the manifest that flags and describes this JAR file as an Apama Java application. You can do this by setting up a new builder in the project properties in Apama Studio or through the command line. For the sake of simplicity, the standard command line calls are described below:
1. Compile the Java code. For example:
javac -classpath "%APAMA_HOME%/lib/correlator_extension_api5.1.jar;%APAMA_HOME%/lib/util5.1.jar" *.java
2. Package the classes into your JAR file:
jar cf simple-jmon.jar *.class
3. Use the JarProcessor utility to create the manifest for the JAR file. For example, if the JAR is called simple-jmon.jar, enter:
java -classpath "%APAMA_HOME%/lib/correlator_extension_api5.1.jar" com.apama.jmon.annotation.JarProcessor simple-jmon.jar
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.