Commands to a running instance of ImageJ?

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

Commands to a running instance of ImageJ?

Bill Mohler
Can I use system command lines to control the behavior of an instance of
ImageJ that is already open and running? How?
Reply | Threaded
Open this post in threaded view
|

Re: Commands to a running instance of ImageJ?

dscho
Hi,

On Sun, 15 Aug 2010, Bill Mohler wrote:

> Can I use system command lines to control the behavior of an instance of
> ImageJ that is already open and running? How?

You can use the "socket listener" which is turned off by default in plain
ImageJ, but turned on by default in Fiji.

When switched on, a second invocation via the command line will actually
send the arguments (including -macro and -eval) commands to the first
instance and then quit the second instance.

If you do not want to require the socket listener to be switched on, you
will basically have to rewrite it. It is easy if you use RMI (remote
method invocation). See
http://download.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html 
for a tutorial (although you do not need to register anything with a
to-be-started RMI registry, you can just serialize the stub and write it
to disk, where the client can read it).

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: Commands to a running instance of ImageJ?

dscho
Hi Bill,

On Sun, 15 Aug 2010, Bill Mohler wrote:

> I am finding that an instance launched by javaws is not listening
> properly for commands even when the listener is selected once it is
> running. Does jauaws somehow nullify the listener? Is it possible the
> listening instance has a different name than the name by which if was
> called to run?

You mean webstart? Well, there are a few things WebStart cannot do, for
security reasons. And if I am not mistaken, listening on sockets or doing
RMI is one of them. Sorry, I do not remember, I would have to read the
documentation about that.

> Related question: can you give me an example of a command line that
> would normally be caught by a listening instance and executed?


        fiji -eval 'print("Hello, World");'

(It should work with java -Dplugins.dir=/path/to/plugins/ -jar
/path/to/ij.jar -eval 'print("Hello, Bill");' just the same if the socket
listener is enabled.)

Ciao,
Johannes