Examples of StreamGobbler


Examples of org.rssowl.core.util.StreamGobbler

    commands.add(rssowlExe.toString());

    Process proc = Runtime.getRuntime().exec(commands.toArray(new String[commands.size()]));

    /* Let StreamGobbler handle error message */
    StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream());

    /* Let StreamGobbler handle output */
    StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream());

    /* Flush both error and output streams */
    errorGobbler.schedule();
    outputGobbler.schedule();

    return proc.waitFor() == 0 ? false : true;
  }
View Full Code Here

Examples of org.rssowl.core.util.StreamGobbler

    commands.add(rssowlExe.toString());

    Process proc = Runtime.getRuntime().exec(commands.toArray(new String[commands.size()]));

    /* Let StreamGobbler handle error message */
    StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream());

    /* Let StreamGobbler handle output */
    StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream());

    /* Flush both error and output streams */
    errorGobbler.schedule();
    outputGobbler.schedule();
  }
View Full Code Here

Examples of org.rssowl.core.util.StreamGobbler

    else if (Application.IS_MAC) {
      try {
        Process proc = Runtime.getRuntime().exec("/usr/bin/open " + link); //$NON-NLS-1$

        /* Let StreamGobbler handle error message */
        StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream());

        /* Let StreamGobbler handle output */
        StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream());

        /* Flush both error and output streams */
        errorGobbler.schedule();
        outputGobbler.schedule();
      }

      /* Show error message, default browser could not be launched */
      catch (IOException e) {
        Activator.getDefault().logError(e.getMessage(), e);
        showErrorIfExternalBrowserFails(null);
      }
    }

    /* Launch default browser on Linux & Solaris */
    else {

      /* Run browser in a seperate thread */
      Thread launcher = new Thread("") { //$NON-NLS-1$
        @Override
        public void run() {
          try {

            /* Return early if shutting down */
            if (Controller.getDefault().isShuttingDown())
              return;

            /* The default browser was successfully launched once, use again */
            if (fgWebBrowserSuccessfullyOpened) {
              Process proc = Runtime.getRuntime().exec(fgWebBrowser + " -remote openURL(" + link + ")"); //$NON-NLS-1$ //$NON-NLS-2$

              /* Let StreamGobbler handle error message */
              StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream());

              /* Let StreamGobbler handle output */
              StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream());

              /* Flush both error and output streams */
              errorGobbler.schedule();
              outputGobbler.schedule();
            }

            /* The default browser was not yet launched, try NS and Mozilla */
            else {
              Process proc = openWebBrowser(link);
              fgWebBrowserSuccessfullyOpened = true;

              if (proc != null) {

                /* Let StreamGobbler handle error message */
                StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream());

                /* Let StreamGobbler handle output */
                StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream());

                /* Flush both error and output streams */
                errorGobbler.schedule();
                outputGobbler.schedule();
              }

              /* Wait for this process */
              try {
                if (proc != null)
View Full Code Here

Examples of org.rssowl.core.util.StreamGobbler

        /* Execute custom browser */
        try {
          Process proc = Runtime.getRuntime().exec(executable);

          /* Let StreamGobbler handle error message */
          StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream());

          /* Let StreamGobbler handle output */
          StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream());

          /* Flush both error and output streams */
          errorGobbler.schedule();
          outputGobbler.schedule();

          /* Wait for the process to terminate */
          proc.waitFor();
        } catch (IOException e) {
          Activator.safeLogError(e.getMessage(), e);
View Full Code Here

Examples of org.rssowl.core.util.StreamGobbler

   * @param download the requested file to download from the service.
   */
  public void download(DownloadRequest download) {
    AttachmentDownloadTask task = new AttachmentDownloadTask(download);
    if (InternalOwl.TESTING) //Support to test the download service from JUnit
      internalDownload(download, new StreamGobbler(null), new NullProgressMonitor());
    else if (!fDownloadQueue.isQueued(task))
      fDownloadQueue.schedule(task);
  }
View Full Code Here

Examples of org.rssowl.core.util.StreamGobbler

      OutputStream outputStream = proc.getOutputStream();
      outputStream.write(message.toString().getBytes());
      outputStream.close();

      /* Let StreamGobbler handle error message */
      StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream());

      /* Let StreamGobbler handle output */
      StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream());

      /* Flush both error and output streams */
      errorGobbler.schedule();
      outputGobbler.schedule();
    }
  }
View Full Code Here

Examples of scalaExec.scalaLab.StreamGobbler

            try {
                Runtime rt = Runtime.getRuntime();
                Process javaProcess = rt.exec(command);
                // an error message?
                StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

                // kick them off
                errorGobbler.start();
                outputGobbler.start();

                // any error???
                javaProcess.waitFor();
                int rv = javaProcess.exitValue();
                String commandString = command[0]+"  "+command[1]+"  "+command[2];
                if (rv==0) {
                 System.out.println("Process:  "+commandString+"  exited successfully ");
                  generateScriptCodeButton.setEnabled(true);
                   statusAreaBottom.setText("Step5:  You can proceed now to create a draft script that utilizes your Java-based  ODE integrator");
                }
                else
                 System.out.println("Process:  "+commandString+"  exited with error, error value = "+rv);

                } catch (IOException exio) {
                    System.out.println("IOException trying to executing "+command);
                    exio.printStackTrace();

                }
               catch (InterruptedException ie) {
                    System.out.println("Interrupted Exception  trying to executing "+command);
                    ie.printStackTrace();
                }
  
                    }
         });
        
                 // Compile with the internal compiler
                 compileJavaInternalCompilerButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
        String currentWorkingDirectory = GlobalValues.workingDir;
          JFileChooser chooser = new JFileChooser(currentWorkingDirectory);
          int ret = chooser.showOpenDialog(ODEWizardFrame);

          if (ret != JFileChooser.APPROVE_OPTION) {
                return;
              }
         File f = chooser.getSelectedFile();
         String javaFile=null;
         try {
            javaFile = f.getCanonicalPath();
            }
         catch (IOException ex) {
               System.out.println("I/O Exception in getCanonicalPath");
               ex.printStackTrace();
         }

   //   extract the path specification of the generated Java class that implements the ODE solution method,
  //    in order to update the ScalaSci class path
      String SelectedFileWithPath = f.getAbsolutePath();
      String SelectedFilePathOnly = SelectedFileWithPath.substring(0, SelectedFileWithPath.lastIndexOf(File.separatorChar));

      if (GlobalValues.ScalaSciClassPath.length()==0)
          GlobalValues.ScalaSciClassPath=".";
      if (GlobalValues.ScalaSciClassPath.indexOf(SelectedFilePathOnly)==-1)  {
        GlobalValues.ScalaSciClassPathComponents.add(0,SelectedFilePathOnly);
        GlobalValues.ScalaSciClassPath = GlobalValues.ScalaSciClassPath+File.pathSeparator+SelectedFilePathOnly;
        }
          // update also the ScalaSciClassPath property
      StringBuilder fileStr = new StringBuilder();
      Enumeration enumDirs = GlobalValues.ScalaSciClassPathComponents.elements();
      while (enumDirs.hasMoreElements())  {
         Object ce = enumDirs.nextElement();
         fileStr.append(File.pathSeparator+(String)ce);
    }
    GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString());

      ClassLoader parentClassLoader = getClass().getClassLoader();
      GlobalValues.extensionClassLoader = new  ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader);

      // update GUI components to account for the updated ScalaSci classpath
                scalaExec.scalaLab.scalaLab.updateTree();
               
      String [] command  = new String[11];
       String toolboxes = "";
       for (int k=0; k<GlobalValues.ScalaSciClassPathComponents.size();k++)
         toolboxes = toolboxes+File.pathSeparator+GlobalValues.ScalaSciClassPathComponents.elementAt(k);

        // compile the temporary file
       command[0] "java";
       command[1] = "-classpath";
       command[2] "."+File.pathSeparator+GlobalValues.jarFilePath+File.pathSeparator+toolboxes+File.pathSeparator+SelectedFilePathOnly;
       command[3] "com.sun.tools.javac.Main";    // the name of the Java  compiler class
       command[4] = "-classpath";
       command[5] =  command[2];
       command[6] = "-sourcepath";
       command[7] =  command[2];
       command[8] = "-d";   // where to place output class files
       command[9] = SelectedFilePathOnly;
       command[10] = SelectedFileWithPath;
       String compileCommandString = command[0]+"  "+command[1]+"  "+command[2]+" "+command[3]+" "+command[4]+" "+command[5]+" "+command[6]+" "+command[7]+" "+command[8]+" "+command[9]+" "+command[10];


       System.out.println("compileCommand Java= "+compileCommandString);

            try {
                Runtime rt = Runtime.getRuntime();
                Process javaProcess = rt.exec(command);
                // an error message?
                StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

                // kick them off
                errorGobbler.start();
                outputGobbler.start();

                // any error???
                javaProcess.waitFor();
                int rv = javaProcess.exitValue();
                if (rv==0) {
View Full Code Here

Examples of scalaExec.scalaLab.StreamGobbler

            try {
                Runtime rt = Runtime.getRuntime();
                Process javaProcess = rt.exec(command);
                // an error message?
                StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

                // kick them off
                errorGobbler.start();
                outputGobbler.start();

                // any error???
                javaProcess.waitFor();
                rv = javaProcess.exitValue();
                String commandString = command[0]+"  "+command[1]+"  "+command[2];
                if (rv==0)
                 System.out.println("Process:  "+commandString+"  exited successfully ");
                else
                 System.out.println("Process:  "+commandString+"  exited with error, error value = "+rv);

                } catch (IOException exio) {
                    System.out.println("IOException trying to executing "+command);
                    exio.printStackTrace();

                }
               catch (InterruptedException ie) {
                    System.out.println("Interrupted Exception  trying to executing "+command);
                    ie.printStackTrace();
                }

       tempFile.delete(); // delete the temporary source file

       if (rv==0)  {  // compilation success: proceed to run
             command  = new String[4];   // the run command
             command[0] "java";
             command[1] = "-cp";
             command[2] "."+ File.pathSeparator+ GlobalValues.jarFilePath+File.pathSeparator+
                scalalab.JavaGlobals.ejmlFile+File.pathSeparator+
                scalalab.JavaGlobals.jsciFile+File.pathSeparator+
                scalalab.JavaGlobals.mtjColtSGTFile+File.pathSeparator+
                scalalab.JavaGlobals.ApacheCommonsFile+File.pathSeparator+                    
                scalalab.JavaGlobals.jfreechartFile+File.pathSeparator+
                scalalab.JavaGlobals.numalFile+File.pathSeparator+
                scalalab.JavaGlobals.LAPACKFile+File.pathSeparator+
                scalalab.JavaGlobals.ARPACKFile+File.pathSeparator+
                scalalab.JavaGlobals.JASFile+File.pathSeparator+homePath;
             command[3] =  className;    // the name of the Scala compiler class

                  try {
               Runtime rt = Runtime.getRuntime();
               Process javaProcess = rt.exec(command);
                // an error message?
               StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

                // kick them off
               errorGobbler.start();
               outputGobbler.start();

                // any error???
                javaProcess.waitFor();
                rv = javaProcess.exitValue();
                String commandString = command[0]+"  "+command[1]+"  "+command[2]+" "+command[3];
View Full Code Here

Examples of scalaExec.scalaLab.StreamGobbler

      
            try {
                Runtime rt = Runtime.getRuntime();
                Process javaProcess = rt.exec(command);
                // an error message?
                StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

                // kick them off
                errorGobbler.start();
                outputGobbler.start();

                // any error???
                javaProcess.waitFor();
                int rv = javaProcess.exitValue();
                String commandString = command[0]+"  "+command[1]+"  "+command[2];
                if (rv==0)
                 System.out.println("Process:  "+commandString+"  exited successfully ");
                else
                 System.out.println("Process:  "+commandString+"  exited with error, error value = "+rv);

                } catch (IOException exio) {
                    System.out.println("IOException trying to executing "+command);
                    exio.printStackTrace();

                }
               catch (InterruptedException ie) {
                    System.out.println("Interrupted Exception  trying to executing "+command);
                    ie.printStackTrace();
                }

       tempFile.delete(); // delete the temporary source file

       if (rv==0) {  // compilation success: proceed to run
             command  = new String[4];   // the run command
             command[0] "java";
             command[1] = "-cp";
             command[2] "."+ File.pathSeparator+ pathOfCanonicalClassName+File.pathSeparator+
                     GlobalValues.jarFilePath+File.pathSeparator+
                     scalalab.JavaGlobals.jfreechartFile+  File.pathSeparator+
                     scalalab.JavaGlobals.jsciFile+File.pathSeparator+
                     scalalab.JavaGlobals.numalFile+  File.pathSeparator+
                     scalalab.JavaGlobals.mtjColtSGTFile+  File.pathSeparator+
                     scalalab.JavaGlobals.ApacheCommonsFile+File.pathSeparator+
                     scalalab.JavaGlobals.ejmlFile+  File.pathSeparator+
                     scalalab.JavaGlobals.LAPACKFile+File.pathSeparator +
                     scalalab.JavaGlobals.ARPACKFile+File.pathSeparator+
                     scalalab.JavaGlobals.JASFile+
                     File.pathSeparator+homePath+File.separator+toolboxes;
             command[3] =  className;    // the name of the Scala compiler class

                  try {
               Runtime rt = Runtime.getRuntime();
               Process javaProcess = rt.exec(command);
                // an error message?
               StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

                // kick them off
               errorGobbler.start();
               outputGobbler.start();

                // any error???
                javaProcess.waitFor();
                rv = javaProcess.exitValue();
                String commandString = command[0]+"  "+command[1]+"  "+command[2]+" "+command[3];
View Full Code Here

Examples of scalaExec.scalaLab.StreamGobbler

      
            try {
                Runtime rt = Runtime.getRuntime();
                Process javaProcess = rt.exec(command);
                // an error message?
                StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

                // kick them off
                errorGobbler.start();
                outputGobbler.start();

                // any error???
                javaProcess.waitFor();
                int rv = javaProcess.exitValue();
                String commandString = command[0]+"  "+command[1]+"  "+command[2];
                if (rv==0)
                 System.out.println("Process:  "+commandString+"  exited successfully ");
                else
                 System.out.println("Process:  "+commandString+"  exited with error, error value = "+rv);

                } catch (IOException exio) {
                    System.out.println("IOException trying to executing "+command);
                    exio.printStackTrace();

                }
               catch (InterruptedException ie) {
                    System.out.println("Interrupted Exception  trying to executing "+command);
                    ie.printStackTrace();
                }

       tempFile.delete(); // delete the temporary source file

       if (rv==0) {  // compilation success: proceed to run
             command  = new String[4];   // the run command
             command[0] "java";
             command[1] = "-cp";
             command[2] "."+ File.pathSeparator+ pathOfCanonicalClassName+File.pathSeparator
               +scalalab.JavaGlobals.ejmlFile+File.pathSeparator
               +scalalab.JavaGlobals.jsciFile+File.pathSeparator
               +scalalab.JavaGlobals.mtjColtSGTFile+File.pathSeparator
               +scalalab.JavaGlobals.ApacheCommonsFile+File.pathSeparator
               +scalalab.JavaGlobals.numalFile+File.pathSeparator
               +scalalab.JavaGlobals.LAPACKFile+File.pathSeparator
               +scalalab.JavaGlobals.ARPACKFile+File.pathSeparator;
             command[3] =  className;    // the name of the Scala compiler class

                  try {
               Runtime rt = Runtime.getRuntime();
               Process javaProcess = rt.exec(command);
                // an error message?
               StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");

                // any output?
                StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");

                // kick them off
               errorGobbler.start();
               outputGobbler.start();

                // any error???
                javaProcess.waitFor();
                rv = javaProcess.exitValue();
                String commandString = command[0]+"  "+command[1]+"  "+command[2]+" "+command[3];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.