That is just evil. It reminds me of the hacks for browser detection. And is as 
reliable.

The 'right' way to do it is with System properties. You might need to query a 
few to get at what you're looking for, though. 
The on point ones are:
java.specification.version
java.vendor
java.version
java.vm.specification.version
java.vm.version

It really depends on what you're trying to discover.

On the other hand, if you're trying to find out if Timer is available, then 
what you've got is appropriate. It's when you extrapolate from that to other 
properties of the system that you will get into trouble.

On Thursday 26 September 2002 08:17 am, jean-frederic clere wrote:
> Stefan Bodewig wrote:
> > On Thu, 26 Sep 2002, jean-frederic clere
> >
> > <[EMAIL PROTECTED]> wrote:
> >>Has someone a better solution or an idea?
> >
> > Try to load a class and catch the ClassNotFoundException - properties
> > have not been reliable so far.  But then again be careful with the
> > class you chose, Kaffe will include ThreadLocal (and therefore look
> > like 1.2) but doesn't include Swing for example.
>
> Something like the following to check that it is at least 1.3:
> +++
> import java.util.Timer;
> public class Version {
>    static public void main(String[] args) {
>      try {
>        Timer time = new Timer();
>        time.cancel();
>      }
>      catch (Exception ex) {
>          System.out.println("Exception " + ex );
>          ex.printStackTrace();
>      }
>    }
> }
> +++
>
> > Stefan
> >
> > --
> > To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to