Login  Register

Re: Version Detection?

Posted by John Hayes-5 on Oct 06, 2007; 9:55pm
URL: http://imagej.273.s1.nabble.com/Version-Detection-tp3698245p3698251.html

If you're interested in dynamically determining if a class or method  
is available, check out the introspection features of Java. This page  
has a brief overview: http://www.cs.grinnell.edu/~rebelsky/Courses/ 
CS223/2004F/Handouts/introspection.html. Also, checkout the "Class"  
class in Javadocs and this tutorial: http://java.sun.com/docs/books/ 
tutorial/reflect/class/index.html.

To my knowledge there is no way to determine that a class exists in  
Java without throwing an exception with the Class.forName
("ij.plugin.FITS_Reader") method (unless you'd like to write your own  
ClassLoader). It's not ideal, but in the exception handler you can  
redirect the control flow such that you can attempt to create a new  
instance of the FITS class.

The simplest and cleanest solution would be to just require at least  
version 1.38f and use Rasband's suggestion to abort the plugin if  
that requirement is not satisfied.

Best regards,

John

On Oct 6, 2007, at 4:16 PM, Andy Puckett wrote:

> I would also accept a routine that tells me whether a certain class  
> is defined or not.
> Specifically, this concerns
> the change as of ImageJ 1.38f from FITS to FITS_Reader/FITS_Writer.
>
> Thanks,
> Andy
>
> ----- Original Message -----
> From: Andy Puckett <[hidden email]>
> Date: Saturday, October 6, 2007 10:15 am
> Subject: Version Detection?
>
>> Can someone tell me if there is a java routine that will detect
>> which version of ImageJ is
>> being run?  I would like to
>> incorporate this into a plugin.
>>
>> Thanks,
>> Andy
>>

--
John A. Hayes, Ph.D.
Department of Applied Science
The College of William & Mary