public static void runBrowser(String url) {
   if (!checkBrowser()) return;
   String commandLine = MimeTypesList.getAppList().getBrowserExec() + " " + url;
   System.out.println("Run: " + commandLine);
   try {
     /*DEBUG*/
     Runtime.getRuntime().exec(commandLine);
   } catch (Exception ex) {
     new ExceptionDialog(
         ex,
         "Failed to run an external web-browser application with commandline<br><code>"
             + commandLine
             + "</code>",
         "Check the application path and command line parameters "
             + "(File-&gt;Preferences-&gt;Resource types).");
   }
 }
 public static boolean checkBrowser() {
   AppList appList = MimeTypesList.getAppList();
   String bpath = appList.getBrowserExec();
   if (bpath != null) if (new File(bpath).isFile()) return true;
   JFileChooser chooser = new JFileChooser();
   chooser.setFileHidingEnabled(false);
   chooser.setDialogTitle(Local.getString("Select the web-browser executable"));
   chooser.setAcceptAllFileFilterUsed(true);
   chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
   /*java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_RESOURCE_FILE");
   if (lastSel != null)
       chooser.setCurrentDirectory(lastSel);*/
   if (chooser.showOpenDialog(App.getFrame()) != JFileChooser.APPROVE_OPTION) return false;
   appList.setBrowserExec(chooser.getSelectedFile().getPath());
   CurrentStorage.get().storeMimeTypesList();
   return true;
 }
  boolean checkApp(MimeType mt) {
    String appId = mt.getAppId();
    AppList appList = MimeTypesList.getAppList();
    File d;
    if (appId == null) {
      appId = Util.generateId();
      d = new File("/");
    } else {
      File exe = new File(appList.getFindPath(appId) + "/" + appList.getExec(appId));
      if (exe.isFile()) return true;
      d = new File(exe.getParent());
      while (!d.exists()) d = new File(d.getParent());
    }
    SetAppDialog dlg =
        new SetAppDialog(
            App.getFrame(),
            Local.getString(
                Local.getString("Select the application to open files of type")
                    + " '"
                    + mt.getLabel()
                    + "'"));
    Dimension dlgSize = new Dimension(420, 300);
    dlg.setSize(dlgSize);
    Dimension frmSize = App.getFrame().getSize();
    Point loc = App.getFrame().getLocation();
    dlg.setLocation(
        (frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
    dlg.setDirectory(d);
    dlg.appPanel.argumentsField.setText("$1");
    dlg.setVisible(true);
    if (dlg.CANCELLED) return false;
    File f = new File(dlg.appPanel.applicationField.getText());

    appList.addOrReplaceApp(
        appId,
        f.getParent().replace('\\', '/'),
        f.getName().replace('\\', '/'),
        dlg.appPanel.argumentsField.getText());
    mt.setApp(appId);
    /*appList.setFindPath(appId, chooser.getSelectedFile().getParent().replace('\\','/'));
    appList.setExec(appId, chooser.getSelectedFile().getName().replace('\\','/'));*/
    CurrentStorage.get().storeMimeTypesList();
    return true;
  }
 void runApp(String fpath) {
   MimeType mt = MimeTypesList.getMimeTypeForFile(fpath);
   if (mt.getMimeTypeId().equals("__UNKNOWN")) {
     mt = addResourceType(fpath);
     if (mt == null) return;
   }
   if (!checkApp(mt)) return;
   String[] command = MimeTypesList.getAppList().getCommand(mt.getAppId(), fpath);
   if (command == null) return;
   /*DEBUG*/
   System.out.println("Run: " + command[0]);
   try {
     Runtime.getRuntime().exec(command);
   } catch (Exception ex) {
     new ExceptionDialog(
         ex,
         "Failed to run an external application <br><code>" + command[0] + "</code>",
         "Check the application path and command line parameters for this resource type "
             + "(File-&gt;Preferences-&gt;Resource types).");
   }
 }