4 Replies Latest reply on Jun 16, 2010 1:00 PM by Aaronius9er9er

    Air executing JRE installer - works in Eclipse, not as exe

    Aaronius9er9er

      Hi guys.  I'm making an AIR app that, in Windows, determines if the user has Java installed and, if not, installs it by executing the JRE "online" installer (jre-6u20-windows-i586-iftw-rv.exe - downloadable from here: http://www.java.com/en/download/manual.jsp).  Here's my code:

       

       

      package
      {
           import flash.desktop.NativeProcess;
           import flash.desktop.NativeProcessStartupInfo;
           import flash.events.Event;
           import flash.events.IOErrorEvent;
           import flash.events.NativeProcessExitEvent;
           import flash.events.ProgressEvent;
           import flash.filesystem.File;
           
           import mx.controls.Alert;
      
           public class JavaUpgrade
           {
                protected var nativeProcess:NativeProcess;
                
                public function upgrade(installerPath:String):void
                {
                     var info:NativeProcessStartupInfo = new NativeProcessStartupInfo();
                     info.executable = File.applicationDirectory.resolvePath(installerPath);
                     Alert.show('upgrade called: ' + info.executable.nativePath);
                     info.workingDirectory = File.applicationDirectory;
                     
                     nativeProcess = new NativeProcess();
                     addListeners(nativeProcess);
                     nativeProcess.start(info);
                }
                
                protected function addListeners(nativeProcess:NativeProcess):void
                {
                     if (nativeProcess)
                     {
                          nativeProcess.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, outputDataHandler);
                          nativeProcess.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, errorHandler);
                          nativeProcess.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR, errorHandler);
                          nativeProcess.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, errorHandler);
                          nativeProcess.addEventListener(NativeProcessExitEvent.EXIT, exitHandler);
                     }
                }
                
                protected function outputDataHandler(event:ProgressEvent):void
                {
                     var output:String = nativeProcess.standardOutput.readUTFBytes(
                               nativeProcess.standardOutput.bytesAvailable);
                     Alert.show(output);
                }
                
                protected function errorHandler(event:Event):void
                {
                     Alert.show(event.toString());
                }
                
                protected function exitHandler(event:NativeProcessExitEvent):void
                {
                     Alert.show(event.toString());
                }
           }
      }
      

       

       

       

      My code works exactly as expected when I'm debugging the app from Eclipse, but when I create a native installer, install the air app, and then run it, the JRE installer never appears.  I do get the alert that says, "upgrade called: C:\Program Files\JavaInstaller\jre-6u20-windows-i586-iftw-rv.exe" and that exe does exist at that location but it just never shows up.  Nor does any additional process show up in my task manager.  Ideas?  It's baffling.