BrightSide Workbench Full Report + Source Code
WdRuntime.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.wd.common.entities;
19 
24 public class WdRuntime {
25 
26  public static void launch(String program) {
27  launch(program, null);
28  }
29 
30  public static void launch(String program, String params) {
31  String os = System.getProperty("os.name");
32  try {
33  if("Windows 2000".equals(os) && !(program.startsWith("http:") || program.startsWith("file:")))
34  Runtime.getRuntime().exec(
35  new String[] {
36  "cmd",
37  "/c",
38  program.replaceAll(" ", "^ ") + (params != null ? params : "")
39  });
40  else if(os != null && os.indexOf("Windows") > -1)
41  Runtime.getRuntime().exec(
42  new String[] {
43  "cmd",
44  "/c",
45  "start",
46  "\"\"",
47  program + (params != null ? " " + params : "")
48  });
49 // Runtime.getRuntime().exec(
50 // "start " + program +
51 // (params != null ? params : "")
52 // );
53  else if(os != null && os.indexOf("Linux") > -1) {
54  Runtime.getRuntime().exec(
55  new String[] {
56  "xdg-open",
57  program + (params != null ? " " + params : "")
58  });
59 
60  }
61  } catch(Exception ex) {
62  java.util.logging.Logger.getLogger("turroclient").log(
63  java.util.logging.Level.SEVERE,
64  "TurroRuntime.execute",
65  ex
66  );
67  }
68  }
69 
70  private WdRuntime() {
71  }
72 
73 }
static void launch(String program, String params)
Definition: WdRuntime.java:30
static void launch(String program)
Definition: WdRuntime.java:26