Attempts to open an application or file using your platform's launcher. The filename parameter is a String specifying the file name and location. The location parameter must be a full path name, or the name of an executable in the system's PATH. In most cases, using a full path is the best op
(String... args)
| 3114 | * @usage Application |
| 3115 | */ |
| 3116 | static public Process launch(String... args) { |
| 3117 | String[] params = null; |
| 3118 | |
| 3119 | if (platform == WINDOWS) { |
| 3120 | // just launching the .html file via the shell works |
| 3121 | // but make sure to chmod +x the .html files first |
| 3122 | // also place quotes around it in case there's a space |
| 3123 | // in the user.dir part of the url |
| 3124 | params = new String[] { "cmd", "/c" }; |
| 3125 | |
| 3126 | } else if (platform == MACOS) { |
| 3127 | params = new String[] { "open" }; |
| 3128 | |
| 3129 | } else if (platform == LINUX) { |
| 3130 | // xdg-open is in the Free Desktop Specification and really should just |
| 3131 | // work on desktop Linux. Not risking it though. |
| 3132 | final String[] launchers = { "xdg-open", "gnome-open", "kde-open" }; |
| 3133 | for (String launcher : launchers) { |
| 3134 | if (openLauncher != null) break; |
| 3135 | try { |
| 3136 | Process p = Runtime.getRuntime().exec(new String[] { launcher }); |
| 3137 | /*int result =*/ p.waitFor(); |
| 3138 | // Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04) |
| 3139 | openLauncher = launcher; |
| 3140 | } catch (Exception ignored) { } |
| 3141 | } |
| 3142 | if (openLauncher == null) { |
| 3143 | System.err.println("Could not find xdg-open, gnome-open, or kde-open: " + |
| 3144 | "the open() command may not work."); |
| 3145 | } |
| 3146 | if (openLauncher != null) { |
| 3147 | params = new String[] { openLauncher }; |
| 3148 | } |
| 3149 | //} else { // give up and just pass it to Runtime.exec() |
| 3150 | //open(new String[] { filename }); |
| 3151 | //params = new String[] { filename }; |
| 3152 | } |
| 3153 | if (params != null) { |
| 3154 | // If the 'open', 'gnome-open' or 'cmd' are already included |
| 3155 | if (params[0].equals(args[0])) { |
| 3156 | // then don't prepend those params again |
| 3157 | return exec(args); |
| 3158 | } else { |
| 3159 | params = concat(params, args); |
| 3160 | return exec(params); |
| 3161 | } |
| 3162 | } else { |
| 3163 | return exec(args); |
| 3164 | } |
| 3165 | } |
| 3166 | |
| 3167 | |
| 3168 | /** |