ImageJ and Jython 2nd try

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

ImageJ and Jython 2nd try

Sebastian Rhode-2

Hi,

Hopefully you can help me out!

I try to use ImageJ and Jython, but I do not get it to work. I installed Jython2.2.1 with the ImageJ java interpreter that runs ImageJ (c:\ImageJ\jre). That worked fine!

I downloades the jython.21.class file (see picture) and typed (in command window):

------------------------------------------------------
C:\ImageJ\jre\bin\java -cp . jython-21
------------------------------------------------------

But all I get is that error and I can not figure out why. And one more question. Does the ImageJ.cfg file has to look like this:

-------------------------------------------------------
.
jre\bin\javaw.exe
-Xmx640m -cp ij.jar ij.ImageJ
-cp C:\jython2.2.1\jython.jar
-------------------------------------------------------

I would be glad, if you could give me hint, what I did wrong.

Best regards,

Sebastian


ImageJ_Jython.png (48K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ and Jython 2nd try

Sami Badawi-2
Hi Sebastian,

Here is the page for how to use Jython with ImageJ:
http://marcora.caltech.edu/jython_imagej_howto.htm

I think that first you have to install Jython to your machine, then you have
 to include the Jython jar file on you classpath. Having a . and jar file in
your local directory is not enough you have to explicitly say something like:

-cp ij.jar;C:\Jython21\jython.jar

I have been experimenting with using the new Java 6 Scripting interface, JSR
223. I got Groovy, JavaScript and JRuby to work right away. Jython did not
work in first try, but I am planning to go back.
I think that JSR 223 is an easier way to access scripting languages from
Java. I have a post about my results:
http://samibadawi.blogspot.com/2008/01/lazy-streams-in-java-groovy-javascript.html

Hope this is helpful,
-Sami Badawi
www.shapelogic.org
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ and Jython 2nd try

ctrueden
In reply to this post by Sebastian Rhode-2
Hi Sebastian,

The "UnsupportedClassVersionError" typically means you are trying to
use a JAR file that was compiled with a newer version of Java than you
are using to execute it. One thing to try is installing Java 6 and
using that rather than the JRE that comes with ImageJ.

-Curtis

On Jan 16, 2008 6:34 AM, Sebastian Rhode
<[hidden email]> wrote:

>
> Hi,
>
>  Hopefully you can help me out!
>
>  I try to use ImageJ and Jython, but I do not get it to work. I installed
> Jython2.2.1 with the ImageJ java interpreter that runs ImageJ
> (c:\ImageJ\jre). That worked fine!
>
>  I downloades the jython.21.class file (see picture) and typed (in command
> window):
>
>  ------------------------------------------------------
>  C:\ImageJ\jre\bin\java -cp . jython-21
>  ------------------------------------------------------
>
>  But all I get is that error and I can not figure out why. And one more
> question. Does the ImageJ.cfg file has to look like this:
>
>  -------------------------------------------------------
>  .
>  jre\bin\javaw.exe
>  -Xmx640m -cp ij.jar ij.ImageJ
>  -cp C:\jython2.2.1\jython.jar
>  -------------------------------------------------------
>
>  I would be glad, if you could give me hint, what I did wrong.
>
>  Best regards,
>
>  Sebastian
>
>
Reply | Threaded
Open this post in threaded view
|

Re: ImageJ and Jython 2nd try

Albert Cardona
In reply to this post by Sebastian Rhode-2
Sebastian,


> And one more
> question. Does the ImageJ.cfg file has to look like this:
>
> -------------------------------------------------------
> .
> jre\bin\javaw.exe
> -Xmx640m -cp ij.jar ij.ImageJ
> -cp C:\jython2.2.1\jython.jar
> j-------------------------------------------------------
>  


Just merge both classpath (-cp) statements into one, like this:

jre\bin\javaw.exe
-Xmx640m -cp ij.jar;C:\jython2.2.1\jython.jar ij.ImageJ

About your error: you need a newer java VM. I suggest 1.6.0; just
download it and make sure that the ImageJ.cfg points to it, instead of
the default.


As for using Jython within ImageJ: I have made a Jython interpreter
available as an ImageJ plugin here:

http://www.mcdb.ucla.edu/research/hartenstein/acardona/software.html#ImageJ%20Jython%20Interpreter

some examples:

http://www.mcdb.ucla.edu/research/hartenstein/acardona/jython_imagej_examples.html


Download the interpreter packed with the utilities:

http://www.mcdb.ucla.edu/research/hartenstein/acardona/plugins/Jython.zip


Albert

--
Albert Cardona
http://www.mcdb.ucla.edu/Research/Hartenstein/acardona