Advertisement
Guest User

Untitled

a guest
Feb 14th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. private void jgobuttonActionPerformed(java.awt.event.ActionEvent evt) {
  2.  
  3. // command we want to run
  4. String cmd = jcommandlabel.getText();
  5.  
  6. class DontEverDoThis implements Runnable {
  7. private final String cmd;
  8.  
  9. DontEverDoThis(final String cmd) {
  10. this.cmd = cmd;
  11. }
  12.  
  13. @Override
  14. public void run() {
  15. try {
  16. Process p = Runtime.getRuntime().exec(cmd);
  17. int i;
  18. InputStream in = p.getInputStream();
  19.  
  20. while((i = in.read()) != -1) {
  21. System.err.print(i);
  22. }
  23.  
  24. } catch(Exception E) { E.printStackTrace(); }
  25. }
  26. }
  27.  
  28. Thread nt = new Thread(new DontEverDoThis(cmd));
  29. nt.start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement