source: trunk/j/doc/extensions.html @ 2

Last change on this file since 2 was 2, checked in by piso, 18 years ago

Initial checkin.

File size: 2.1 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2
3<html>
4
5<head>
6<title>J User's Guide - Extending J</title>
7<LINK REL="stylesheet" HREF="j.css" TYPE="text/css">
8</head>
9
10<body>
11
12<a href="contents.html">Top</a>
13
14<hr>
15
16<h1>Extending J</h1>
17
18<hr>
19
20<p>
21
22J provides a mechanism to support arbitrary user extensions.  You can add a
23line like this to your <a href="preferences.html">preferences</a> file:
24<pre>
25    extension=SampleExtension
26</pre>
27where <code>SampleExtension</code> is the name of a class you've written,
28compiled, and placed in <code>~/.j</code> or <code>C:\.j</code>. The class must
29provide the method <code>public void run( )</code>, and the class itself must
30be declared  <code>public</code>. If these conditions are met, your class
31will be loaded when the editor starts up and the <code>run</code> method will
32be invoked.
33<p>
34One problem you're likely to run into with this is that any editor method or
35member variable referenced in your extension class must be explicitly declared
36<code>public</code> in the editor source; otherwise you'll get an
37<code>IllegalAccessException</code>. The short-term solution to this is to
38hack the editor source and make the thing <code>public</code>; the long-term
39solution is to <a href="mailto:peter@armedbear.org">tell me about it</a> so
40that I can make sure it stays <code>public</code> in the future.
41<p>
42The easiest way to write your extension class is to develop and debug it in the
43j's top-level <code>src</code> directory; the loader will pick it up from
44there, so you don't have to copy it into <code>~/.j</code> every time you
45compile it.  When you're done you should move it into <code>~/.j</code> and
46delete any extraneous copies.
47<p>
48Strictly speaking, your extension class does not have to live in   
49<code>~/.j</code> or <code>C:\.j</code>.  You can also specify the fully
50qualified pathname of your extension's <code>.class</code> file in your
51preferences file, like this:
52<pre>
53    extension=/home/peter/SampleExtension.class
54</pre>
55In this case you must specifically append the <code>.class</code> extension, as
56shown in the example.
57
58</body>
59
60</html>
Note: See TracBrowser for help on using the repository browser.