Personal tools
You are here: Home Developer Reference Adding a New Java Actor to Kepler - A Quick Tutorial

Adding a New Java Actor to Kepler - A Quick Tutorial

Does your new Java actor source use only existing Ptolemy or Kepler classes? Compile and import the actor into Kepler with a few simple steps.

Use Kepler's "Tools->Instantiate Component" menu item to instaniate a preexisting Java class in Kepler.

Adding new Java Actors to versions of Kepler _after_ 1.0.0

Under versions of Kepler after Kepler-1.0.0, see Developing a Hello World Actor using the Kepler Build System and Eclipse.


The text below applies only to Kepler-1.0.0, and does not apply to the Kepler development tree.

Adding new Java Actors to Kepler-1.0.0

For more information, please see section 5.3.2 of the Kepler User Manual

.

 

Under Kepler-1.0.0, adding new Java actors to Kepler requires only an installed version of Kepler and a Java SDK. If you have written an actor in Java that does not use new classes (i.e., classes not currently used in Ptolemy and Kepler), follow the methods described on this page to add the actor to Kepler. If your actor uses new classes, please see Adding New Classes (JARs) to Kepler for instructions.

Navigate to the $KEPLER/lib/ directory in the nightly build or SVN-version of Kepler and look at the file with the relative path 'example/tutorial/HelloWorld.java'. This Java file is a simple Kepler actor. It is defined to be in the package 'example.tutorial' and the constructor extends 'TypedAtomicActor'. Several Ptolemy classes are imported.

To compile this actor, simply open a command window ("Command Prompt" on Windows XP) and change your working directory to $KEPLER/lib.

If you have installed the Java SDK, then enter the following command to compile the HelloWorld actor code and create a HelloWorld.class file in the $KEPLER/lib/example/tutorial/ directory:

javac -cp ../build/kepler.jar ./example/tutorial/HelloWorld.java

The '-cp ..//build/kepler.jar' in the compilation command sets the Java classpath to point to the kepler.jar file in the $KEPLER/build/ directory. This large (~ 18.5 Megabyte) JAR contains all of the compiled Ptolemy and Kepler base classes, and is all that is needed to find the various Ptolemy classes used to compile a new Kepler actor (unless, of course, the new actor needs some additional non-Ptolemy classes). Note: if you are using an SVN checkout of Kepler, the kepler.jar file may be absent. If so, execute 'ant jar' to create it.

The $KEPLER/lib/ directory is on the classpath when Kepler is launched, so Kepler should be able to find the new HelloWorld class file. Launch Kepler and select the 'Tools > Instantiate Component' menu item. Enter the Class name:

example.tutorial.HelloWorld

Leave the 'Location' parameter blank and click 'OK'. The newly compiled HelloWorld actor should appear on the Workflow canvas. Right click the HelloWorld actor and select the "Save in Library...' menu item. Select one or more library locations from the categories in the dialog box and click OK to add the new actor to your local library. To share the new actor with others, select the "File > Export Archive (KAR)..." or right-click the actor and select the "Upload to Repository" menu item.

 

Document Actions