1 Reply Latest reply on Oct 17, 2011 2:16 PM by williamjgrand

    Applications Air need to check Java Runtime with architecture and operating system.

    Jens Eckervogt

      Hello dear Developers,

       

      have been written this example for currect architectures and currect operating system while your Java Runtime was installed.

      I have been created Actionscript class javastartupinfoprovider.as:

      Look this code

       

           public function getStartUpInfo():NativeProcessStartupInfo
                {
                     // Check your supportted operating system:
                     if (NativeProcess.isSupported){
                          Alert.show("Sorry, this nativeProcess doesn't support");
                     }
                     
                     // Binary Java Runtime
                     var result:File = new File;
                     var osName:String = Capabilities.os.toLowerCase();
                     var osArch:String = Capabilities.os.valueOf();
                     var osType:String = Capabilities.os.toString();               
                     
                     // For Windows 32 Bit Version!!
                     if (osName.indexOf("win") > -1 && osArch.indexOf("x86") > -1)
                     {
                          // For Architecture x86 ( 32 Bit Version )
                          var programFile:File = new File("C:\\Program Files\\");
                          // If you are using Java Runtime 32 Bit on Windows 64 Bit Version
                          var programFile_x86:File = new File("C:\\Program Files (x86)\\");
                          if (programFile.exists && programFile_x86.exists)
                          {
                               // 32 Bit ( x86 )
                               for each(var appDir:File in programFile.getDirectoryListing())
                               {
                                    if (appDir.name.toLowerCase().indexOf("java") > -1 && appDir.isDirectory)
                                    {
                                         for each(var subDir:File in appDir.getDirectoryListing())
                                         {
                                              var subDirName:String = subDir_x86.name.toLowerCase();
                                              if (subDirName.indexOf("jre") > -1)
                                              {
                                                   var javaw:File = subDir.resolvePath("bin").resolvePath("javaw.exe");
                                                   if (javawm.exists)
                                                   {
                                                        result = javaw;
                                                        break;
                                                   }
                                              }
                                         }
                                         if (result != null)
                                              break;
                                    }
                               }
                               // 32 Bit on 64 Bit ( x86_x64 )
                               for each(var appDir_x86:File in programFiles_x86.getDirectoryListing())
                               {
                                    if (appDir_x86.name.toLowerCase().indexOf("java") > -1 && appDir_x86.isDirectory)
                                    {
                                         for each(var subDir_x86:File in appDir_x86.getDirectoryListing())
                                         {
                                              var subDirName_x86:String = subDir_x86.name.toLowerCase();
                                              if (subDirName_x86.indexOf("jre") > -1)
                                              {
                                                   var javaw_x86:File = subDir_x86.resolvePath("bin").resolvePath("javaw.exe");
                                                   if (javaw_x86.exists)
                                                   {
                                                        result = javaw_x86;
                                                        break;
                                                   }
                                              }
                                         }
                                         if (result != null)
                                              break;
                                    }
                               }
                          }
                     }
                     
                     // For Windows 64 Bit Version
                     else if (osName.indexOf("win") > -1 && osArch.indexOf("x64") > -1)
                     {
                          // Java Runtime 64 Bit
                          var programFile_x64:File = new File("C:\\Program Files\\");
                          if(programFile_x64.exists)
                          {
                               // 64 Bit ( x64 )
                               for each(var appDir_x64:File in programFiles_x64.getDirectoryListing())
                               {
                                    if (appDir_x64.name.toLowerCase().indexOf("java") > -1 && appDir_x64.isDirectory)
                                    {
                                         for each(var subDir_x64:File in appDir_x64.getDirectoryListing())
                                         {
                                              var subDirName_x64:String = subDir_x64.name.toLowerCase();
                                              if (subDirName_x64.indexOf("jre") > -1)
                                              {
                                                   var javaw_x64:File = subDir_x64.resolvePath("bin").resolvePath("javaw.exe");
                                                   if (javaw_x64.exists)
                                                   {
                                                        result = javaw_x64;
                                                        break;
                                                   }
                                              }
                                         }
                                         if (result != null)
                                              break;
                                    }
                               }
                          }
                     }
                     
                     // For Linux 32 Bit Version
                     else if (osName.indexOf("linux") > -1 && osArch.indexOf("x86") > -1)
                     {
                          
                     }
                     
                     // For Linux 64 Bit Version
                     else if (osName.indexOf("linux") > -1 && osArch.indexOf("x64") > -1)
                     {
                          
                     }
                     
                     // For Mac Intel 32 Bit Version
                     else if (osName.indexOf("mac") > -1 && osType.indexOf("Intel") > -1 && osArch.indexOf("x86") -1)
                     {
                          
                     }
                     return result;
                }
      

       

       

      Did you see that supportted architecture?

      What is it different?

      x86 = 32 Bit

      x86_x64 = 32 Bit-Applications work on 64 Bit Operating System

      x64 = 64 Bit

       

      If you develop an example check install process by Java Runtime while your Java Runtime does not install on your operatingsystem and your currect architecture.

       

      I hope you because my idea is sure for all supportted ways on developed Application Air 2.5x

       

      It is true or worng?

      I want to know about architectures - if you are using on 64 Bit operating system than Java Runtime with 64 Bit Version will to install currectly.

      Can you help sometimes?

       

      Best merry xmas! SnakeMedia