Share this page 

Start an executable on the client (this howto is deprecated)Tag(s): DEPRECATED


(with Netscape capabilities classes)
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import netscape.security.*;

public class LauchNotepad extends Applet 
  implements ActionListener {
  Button lauchButton;
  TextField filename;
  String browserName;
  boolean securitySupported = false;
     
  public void init() {
    setLayout(new FlowLayout());
    Label label = 
      new Label("Lauch notepad with the specified file");
    add(label);
    lauchButton = new Button("call NOTEPAD");
    add(lauchButton);
    lauchButton.addActionListener(this);
    filename = new TextField(20);
    add(filename);
    browserName = System.getProperty("java.vendor");
    if (browserName.indexOf("Netscape") > -1)
       securitySupported = true;
    setSize(200, 200);
    }

  public void actionPerformed(ActionEvent evt)  {
    if (evt.getSource() == lauchButton) {   
       if (securitySupported) {
          PrivilegeManager.enablePrivilege("UniversalExecAccess");
          try {
            Runtime.getRuntime().exec("notepad.exe " + filename.getText());
            }
          catch(Exception e) {
            e.printStackTrace();        
            }
          }
       else {
          getAppletContext().showStatus("security not installed");
          }         
         }
       }
}