Package scalaExec.scalaLab

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


            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

      
            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

      
            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

Related Classes of scalaExec.scalaLab.StreamGobbler

Copyright © 2018 www.massapicom. 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.