Package java.lang

Examples of java.lang.Runtime$Shutdown


import java.lang.Runtime;
import java.lang.Process;

public class RuntimeExec {
  public static void main(String[] args) throws java.io.IOException, java.lang.InterruptedException {
    Runtime runtime = Runtime.getRuntime();
    String ieStr = null;
    String charmapStr = null;
    String[] firefox = new String[2];
   
    if(System.getProperty("os.name").equals("windows")){
      System.out.println("Executing internet explorer");
      ieStr = "\"c:\\program files\\internet explorer\\iexplore.exe\" http://www.google.com";
    } else {
      System.out.println("Executing Firefox using string");
      ieStr = "firefox http://www.google.com";
    }
    Process ie = runtime.exec(ieStr);
   
    if(System.getProperty("os.name").equals("windows")){
      System.out.println("Executing firefox");
      firefox[0] = "c:\\program files\\mozilla firefox\\firefox.exe";
      firefox[1] = "http://www.google.com";
    } else {
      System.out.println("Executing Firefox using array");
      firefox[0] = "firefox";
      firefox[1] = "http://www.google.com";
    }
    Process ff = runtime.exec(firefox);

    boolean ffSuccess = false;
    boolean ieSuccess = false;
    while(!(ieSuccess && ffSuccess)){
      if(!ffSuccess){
        try{
          System.out.println("Exit value from string exec: " + ff.exitValue());
          ffSuccess = true;
        } catch(IllegalThreadStateException e) {}
      }
      if(!ieSuccess){
        try{
          System.out.println("Exit value from array exec: " + ie.exitValue());
          ieSuccess = true;
        } catch(IllegalThreadStateException e) {}
      }
    }
    if(System.getProperty("os.name").equals("windows")){
      System.out.println("Executing and waiting for charmap");
      charmapStr = "c:\\windows\\system32\\charmap.exe";
    } else {
      System.out.println("Executing and waiting for firefox");
      charmapStr = "firefox http://www.google.com";
    }
    Process cm = runtime.exec(charmapStr);
    System.out.println("Exit value: " + cm.waitFor());
  }
View Full Code Here


  return (result);
}
public boolean action (Event evt, Object arg)
{

Runtime r=Runtime.getRuntime();


if (isinapp)
  mfe=new MyFrameError("An error occured , You can't launch xlock");
  else
  mfe=new MyFrameError("An error occured , You can't launch xlock");
  //mfe=new MyFrameError("You can't launch by a Browser");

mfe.resize(350,150);

if (evt.target == blaunch || evt.target == blaunchinw)
  {
  String label= (String) arg;
  String cmdlinexlock="xlock ";
  if (evt.target == blaunchinw ) cmdlinexlock=cmdlinexlock.concat("-inwindow ");
  for (int i=0;i<nbcoption;i++)
    {
    if (!valueOption[i].equals(""))
      {
      cmdlinexlock=cmdlinexlock.concat(cmdlineOption[i]+" "+valueOption[i]+" ");
      }
    }
  cmdlinexlock=cmdlinexlock.concat(getBooleanOption());
  cmdlinexlock=cmdlinexlock.concat(" -mode ");
  cmdlinexlock=cmdlinexlock.concat(lst.getSelectedItem());
  try {
  System.out.println(cmdlinexlock);
  r.getRuntime().exec(cmdlinexlock); }
      catch ( Exception e )
        {mfe.show();}
  return true;}
else
  if (evt.target == coptions)
View Full Code Here

TOP

Related Classes of java.lang.Runtime$Shutdown

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.