How to use an own plugin or class in javascript?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use an own plugin or class in javascript?

Christian Moll
Hello,

I want to use one of my plugins from Javascript.

importClass(ClassName)

always returns this message:

ReferenceError: "ClassName" is not defined. (<Unknown source>#4) in
<Unknown source> at line number 4

Is it not possible to use own classes within the javascripting
functionality of ImageJ.

Best Christian
-----------------------------------------------------------------
Christian Moll  -  Ingenieur de Recherche
[hidden email]
-----------------------------------------------------------------
CRP Henri Tudor  -  http://santec.tudor.lu
2A, rue Kalchesbrück
L-1852 Luxembourg
-----------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: How to use an own plugin or class in javascript?

dscho
Hi,

On Wed, 28 Apr 2010, Christian Moll wrote:

> I want to use one of my plugins from Javascript.
>
> importClass(ClassName)
>
> always returns this message:
>
> ReferenceError: "ClassName" is not defined. (<Unknown source>#4) in
> <Unknown source> at line number 4

The problem is that the script engine does not use ImageJ's class loader.
In Fiji, we use a specific Javascript engine, so we can set that class
loader explicitely:

http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi?p=fiji.git;a=blob;f=src-plugins/Javascript_/Javascript_Interpreter.java;h=3f6c658a1c2f9b67f218b0b33b59833e6defe3e5;hb=717e4875ba8c5e57f7c4427ce8872eb412adbe03#l25

Happily, it is relatively easy to convince the Javascript Engine of JDK6
to use ImageJ's class loader:

http://pacific.mpi-cbg.de/cgi-bin/gitweb.cgi?p=ImageJA.git;a=commitdiff;h=e3bed9d7810443ff9033e25c6a12570fe8ebf672;hb=refs/heads/master

With this patch, it works here.

Ciao,
Johannes

P.S.: Note that in my experiments, I had to use something like
"importClass(Packages.Simulate_Color_Blindness);" to import the class,
i.e. the prefix "Packages." was crucial.