Login  Register

Re: Quicktime installed?

Posted by Bill Mohler on Mar 04, 2011; 8:24pm
URL: http://imagej.273.s1.nabble.com/Quicktime-installed-tp3685482p3685487.html

I think I found my problem below.  In short, if QTJava.zip is not in the
classpath on a client machine, then the classloader gags when reading in
this class because of the need to catch a QTException (for which no
class exists yet in the client JRE).  So I'm now running a different
shorter version of the class, leaving out the second try/catch block.  
It has the desired effect now, prompting the user to download and
install QuickTime if they want to continue.  Code is here:


import ij.IJ;
import ij.gui.GenericDialog;
import ij.plugin.PlugIn;
import quicktime.QTException;
import quicktime.QTSession;
import quicktime.util.QTBuild;

public class QT_Test2 {

     public static void run(String arg) {
         IJ.log("Testing QuickTime installation:");
         boolean success = false;
         boolean hasQT = false;
         try {
             Class.forName("quicktime.QTSession");
             hasQT = true;
         }
         catch (ClassNotFoundException cnfe) {
         }
         if (!hasQT ) {
             IJ.log("QuickTime not found.");
             GenericDialog gd = new GenericDialog("QuickTime not found");
             gd.addHelp("http://www.apple.com/quicktime/download/");
             gd.addMessage("Your computer does not have QuickTime
installed.  To fix this:\n\n" +
                     "1. Please click 'Install QuickTime' below to begin
QuickTime installation. \n\n" +
                     "2. Quit GLOWormJ and relaunch to view and analyze
GLOWorm movies.");
             gd.centerDialog(true);
             gd.setOKLabel("Quit GLOWormJ");
             gd.setHelpLabel("Install QuickTime");
             gd.showDialog();
             if (gd.wasOKed()) IJ.run("Quit");
             return;
         }

         IJ.log("QuickTime is installed.");

     }
}


On 3/4/11 12:24 PM, Bill Mohler wrote:

> I'm using this slightly modified version of Wilhelm's class.  It worked
> when I directly force hasQT to stay false in the code.  But when I leave
> it with the option for hasQT to go true and I include in my project and
> call it from a startup macro on a machine without QuickTime installed
> (always Windows for this test), I still get an exception trace, which
> I'm also pasting here below the code?   Shouldn't the catch (Throwable
> throwable) be handling this exception?  Maybe I need to catch
> QTException rather than Throwable?  Thanks for any advice!
>
>
> import ij.IJ;
> import ij.gui.GenericDialog;
> import ij.plugin.PlugIn;
> import quicktime.QTException;
> import quicktime.QTSession;
> import quicktime.util.QTBuild;
>
> public class QT_Test2 {
>
>       public static void run(String arg) {
>           IJ.log("Testing QuickTime installation:");
>           boolean success = false;
>           boolean hasQT = false;
>           try {
>               Class.forName("quicktime.QTSession");
>               hasQT = true;
>           }
>           catch (Throwable throwable) {
>           }
>           if (!hasQT ) {
>               IJ.log("QuickTime not found.");
>               GenericDialog gd = new GenericDialog("QuickTime not found");
>               gd.addHelp("http://www.apple.com/quicktime/download/");
>               gd.addMessage("Your computer does not have QuickTime
> installed.  To fix this:\n\n" +
>                       "1. Please click 'Install QuickTime' below to begin
> QuickTime installation. \n\n" +
>                       "2. Quit GLOWormJ and relaunch to view and analyze
> GLOWorm movies.");
>               gd.centerDialog(true);
>               gd.setOKLabel("Quit GLOWormJ");
>               gd.setHelpLabel("Install QuickTime");
>               gd.showDialog();
>               if (gd.wasOKed()) IJ.run("Quit");
>               return;
>           }
>
>           IJ.log("QuickTime is installed.");
>           try {
>               QTSession.open();
>               success = true;
>           } catch (QTException e) {
>           }
>           if (success&&  QTSession.isInitialized()) {
>               IJ.log("QuickTime initialized.");
>               IJ.log("QuickTime Version: " +
>                       QTSession.getMajorVersion() + "." +
>                       QTSession.getMinorVersion() + "." +
>                       QTSession.getBugFixVersion());
>               IJ.log("QuickTime for Java Version: " +
>                       QTBuild.getVersion() + "." +
>                       QTBuild.getSubVersion() + "." +
>                       QTBuild.getQualifyingSubVersion());
>               QTSession.close();
>               IJ.log("QuickTime seems to be working OK.");
>           }
>           else {
>               IJ.log("Could not initialize Quicktime!");
>           }
>       }
> }
>
>
> java.lang.NoClassDefFoundError: quicktime/QTException
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
> at java.lang.Class.getMethod0(Unknown Source)
> at java.lang.Class.getMethod(Unknown Source)
> at ij.macro.Functions.call(Functions.java:3448)
> at ij.macro.Functions.getStringFunction(Functions.java:252)
> at ij.macro.Interpreter.getStringTerm(Interpreter.java:1161)
> at ij.macro.Interpreter.getString(Interpreter.java:1140)
> at ij.macro.Interpreter.doStatement(Interpreter.java:248)
> at ij.macro.Interpreter.doBlock(Interpreter.java:518)
> at ij.macro.Interpreter.runMacro(Interpreter.java:130)
> at ij.macro.MacroRunner.run(MacroRunner.java:126)
> at java.lang.Thread.run(Unknown Source)
> Caused by: java.lang.ClassNotFoundException: quicktime.QTException
> at java.net.URLClassLoader$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(Unknown Source)
> at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> ... 13 more
>
>
>
>
>
> On 3/1/11 10:19 AM, Bill Mohler wrote:
>> Thanks for sharing this.  I was just coming upon a need for this test
>> myself.
>>
>> Bill
>>
>> On 3/1/11 3:12 AM, Burger Wilhelm wrote:
>>> Sebastian,
>>>
>>> below is the plugin that I use for testing the QT installation. Perhaps it helps.
>>>
>>> --Wilhelm
>>> www.imagingbook.com
>>>
>>>
>>> // --------------------------------------------------------------
>>>
>>> import ij.IJ;
>>> import ij.plugin.PlugIn;
>>> import quicktime.QTException;
>>> import quicktime.QTSession;
>>> import quicktime.util.QTBuild;
>>>
>>> public class QT_Test2 implements PlugIn {
>>>
>>> public void run(String arg) {
>>> IJ.log("Testing QuickTime installation:");
>>> boolean success = false;
>>> boolean hasQT = false;
>>>            try {
>>>                Class.forName("quicktime.QTSession");
>>>                hasQT = true;
>>>            }
>>>            catch (Throwable throwable) {
>>>            }
>>>            if (!hasQT) {
>>>             IJ.log("QuickTime not found.");
>>>             return;
>>>            }
>>>
>>>            IJ.log("QuickTime is installed.");
>>> try {
>>> QTSession.open();
>>> success = true;
>>> } catch (QTException e) {
>>> }
>>> if (success&&    QTSession.isInitialized()) {
>>> IJ.log("QuickTime initialized.");
>>> IJ.log("QuickTime Version: " +
>>> QTSession.getMajorVersion() + "." +
>>> QTSession.getMinorVersion() + "." +
>>> QTSession.getBugFixVersion());
>>> IJ.log("QuickTime for Java Version: " +
>>> QTBuild.getVersion() + "." +
>>> QTBuild.getSubVersion() + "." +
>>> QTBuild.getQualifyingSubVersion());
>>> QTSession.close();
>>> IJ.log("QuickTime seems to be working OK.");
>>> }
>>> else {
>>> IJ.log("Could not initialize Quicktime!");
>>> }
>>> }
>>> }
>>>
>>> // --------------------------------------------------------------
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
>>>> Sebastian Böckmann
>>>> Sent: Monday, February 28, 2011 5:24 PM
>>>> To: [hidden email]
>>>> Subject: Quicktime installed?
>>>>
>>>> Hello,
>>>>
>>>> In my java project I'm using quicktime (QTJava.jar) for video
>>>> processing issues. So far so good, but to release my program I want to
>>>> check if quicktime is installed properly. I use the following code:
>>>>
>>>> try {
>>>>                QTSession.open();
>>>>            } catch (Exception e) {
>>>>                System.out.println("ERROR...");
>>>>                ...
>>>>            }
>>>>
>>> ...