Thanks everyone for such quick responses.  I've never had such immediate response from 
a newsgroup before!

I am going to try some of your suggestions, but what I am really hoping to find is 
this:

I will also be checking if the user has JRE1.4 (via the CODEBASE parameter in the 
OBJECT tag).  I want to check for JRE1.4 and J3d at the same time.  That is, if the 
user doesn't have JRE1.4 and doesn't have J3D, I don't want them to have to download 
just JRE1.4, load the applet again, only to find a message that they don't have J3D, 
and then have to go download that.

Does anyone know a way to detect both at the same time?

Many thanks again,

Andrea Boright

-----Original Message-----
From: Justin Couch [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 14, 2002 1:00 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] j3D detection


Simeon H.K. Fitch wrote:
>>-----Original Message-----
>>From: Discussion list for Java 3D API
>>[mailto:[EMAIL PROTECTED]]On Behalf Of Andrea Boright
>>
>>It looks like the PackageInfo sample can be run as an application
>>only.  I need to detect the presence of Java3D from a web browser
>>(IE6 or NS6.2), either via Javascript or a Java applet.
>>Preferable via javascript (or via parameters on the <object>
>>tag), since I'd like to warn them before any applets get loaded.
>
>
> This is what I do in my application, which should work for an Applet (I
> don't think Class.forName() is a privileged operation):
>
>     /**
>      * Determine if Java 3D is installed.
>      */
>     public static boolean isJ3DInstalled() {
>         try {
>             Class.forName("javax.media.j3d.Canvas3D");
>         }
>         catch(Throwable ex) {
>             return false;
>         }
>         return true;
>     }
>
> You need to catch Throwable, not Exception, as the jar files may be
> available but not the shared libraries/DLLs, which results in an Error being
> thrown.

A better way of doing this, particularly if you have a library for the
application installed is this snippet of code that we use in the j3d.org
code repository loaders. What this does is checks for Java3D minimum
version 1.3 so we know whether or not we have the ability to set the
frequency bits on the runtime structure.

         Boolean bool = (Boolean)AccessController.doPrivileged
         (
             new PrivilegedAction()
             {
                 public Object run()
                 {
                     try
                     {
                         Class cls =

Class.forName("javax.media.j3d.SceneGraphObject");
                         Package pkg = cls.getPackage();

                         return new Boolean(pkg.isCompatibleWith("1.3"));
                     }
                     catch(ClassNotFoundException cnfe)
                     {
                         return Boolean.FALSE;
                     }
                 }
             }
         );

         haveFreqBitsAPI = bool.booleanValue();

--
Justin Couch                         http://www.vlc.com.au/~justin/
Java Architect & Bit Twiddler              http://www.yumetech.com/
Author, Java 3D FAQ Maintainer                  http://www.j3d.org/
-------------------------------------------------------------------
"Humanism is dead. Animals think, feel; so do machines now.
Neither man nor woman is the measure of all things. Every organism
processes data according to its domain, its environment; you, with
all your brains, would be useless in a mouse's universe..."
                                               - Greg Bear, Slant
-------------------------------------------------------------------

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to