...
To use this class as an extension you will also need to create a plugins.xml file which describes your extension to JAS3. Here is an example plugins.xml file for the HelloWorld extension. This file must be saved in a directory called PLUGIN-inf (please create it).
Code Block | |||||||
---|---|---|---|---|---|---|---|
| |||||||
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plugins SYSTEM "http://java.freehep.org/schemas/plugin/1.0/plugin.dtd"> <plugins> <plugin> <information> <name>HelloWorld</name> <author>Tutorial User</author> <version>1.0</version> <description kind="short">HelloWorld extension</description> <description>Illustrates how to write a plugin.</description> <load-at-start/> </information> <plugin-desc class="test.HelloWorldPlugin"/> </plugin> </plugins> |
Finally you need to compile your java file, and package it into a jar file. The easiest way to do this is using ant, a make-like system commonly used by Java projects. Here is an ant build.xml file which will package up your extension into a HelloWorld.jar file, and then install the extension into JAS3.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="all" name="JAS3Tutorial"> <target depends="init,compile,jar,deploy" name="all"/> <target name="init"> <property name="phase" value="1"/> <property name="srcDir" value="phase${phase}"/> <property name="tmpDir" value="tmp/${phase}"/> <property name="jas3Dir" value="/Program Files/Stanford Linear Accelerator Center/JAS3"/> </target> <target name="compile" depends="init"> <mkdir dir="${tmpDir}"/> <javac srcdir="${srcDir}" destdir="${tmpDir}"> <classpath> <fileset dir="${jas3Dir}"> <include name="lib/*.jar"/> </fileset> </classpath> </javac> </target> <target name="jar" depends="compile"> <jar jarfile="HelloWorld.jar"> <fileset dir="${tmpDir}"> <include name="**/*.class"/> </fileset> <fileset dir="."> <include name="PLUGIN-inf/plugins.xml"/> </fileset> </jar> </target> <target name="deploy" depends="jar"> <copy file="HelloWorld.jar" toDir="${user.home}/.JAS3/extensions"/> </target> <target name="clean" depends="init"> <delete dir="tmp"/> </target> </project> |
...