Tutorial Java Archive
1. Getting Zephyr Application to run a jar:
- Download and install the
standalone application
- Optional:
- Download available binary demos: simpleexample.jar idbd.jar
- In Zephyr, go to:
and open the jar file
- Zephyr will start running the jar, you can select data to
plot
- Tips: you can unzip the jar files to use as working example
2. Create your jar:
- Your project needs to import a few definitions to interface
with Zephyr, mainly: the
Clock
class for synchronization,
and the @Monitor
and @IgnoreMonitor
to
specify what data in your code you would like to monitor. These
definitions are included in Zephyr.jar.
Export this file from Zephyr application by going to the menu item and include it into
the classpath of your project.
- To synchronize data with Zephyr:
- Create a new instance of the class
Clock
by
calling Clock clock = new Clock()
. The instance clock
is used to let Zephyr know when to synchronize data.
- Use the annotation
@Monitor
to indicates to
Zephyr what data to monitor. Added before the declaration of a class
means that all the fields of the class will be monitored
- Use
Zephyr.advertise(clock, instance);
to specify to Zephyr the root node
instance
to look for data to monitor. Zephyr will use the annotation @Monitor
and @IgnoreMonitor
to decide what fields and classes to
explore for data. The argument clock
indicates on what
clock the data will be synchronized.
- When
clock.tick()
is called, Zephyr views
collect the data (if necessary) for statistics or the next drawing.
clock.tick()
returns a boolean indicating if the clock
is still running (not terminated). A clock can be terminated by a
user from Zephyr graphic user interface or by a program by calling clock.terminate()
.
- Check the following files in Zephyr code source for
examples:
- Similarly to Java, Zephyr use the
main
method to
start your program. Specify the location of the entry point class to
run in the jar using a manifest file (the path of the file in your jar
should be: META-INF/MANIFEST.MF)
and the Main-Class
entry (same entry to specify the class
with the main method to run for Java). See the MANIFEST.MF of the
SimpleExample project. Note that Eclipse, Netbeans and other Java
editors write this file for you when your export your project(s) into
a runnable jar.
3. Load your jar with the Zephyr application:
- A first test is to check if Java can run your jar without
Zephyr by trying the following command: java
-jar <yourfilename>.jar If Java cannot run it, Zephyr will not
run it either. This test checks that the MANIFEST.MF
file is correct and that the entry class has a static method
main
method.
- Start the Zephyr Application and go to to start running your jar
- If you would like to start your jar automatically when Zephyr
starts, then you can specify the path of the jar file to run at start
up in:
- Additional arguments to the JVM running Zephyr (and your jar)
can be specified in the file Zephyr.ini (zephyr/Zephyr.ini on Linux and Windows and zephyr/Zephyr.app/Contents/MacOS/Zephyr.ini for Mac OS X) after the line -vmargs. One argument per line. See Eclipse.ini for the
file format.
Notes:
- The jar depends on Zephyr.jar but can run directly from Java, without the application
- The overload of calling clock.tick() without the Zephyr application should be negligeable
Related Links: