Advertisement
Guest User

GarciaPL

a guest
Nov 10th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package killsqldeveloper;
  7.  
  8. import java.io.BufferedReader;
  9. import java.io.InputStreamReader;
  10.  
  11. /**
  12.  *
  13.  * @author lciesluk
  14.  */
  15. public class KillSQLDeveloper {
  16.  
  17.     /**
  18.      * @param args the command line arguments
  19.      */
  20.     public static void main(String[] args) {
  21.         try {
  22.             Process exec = Runtime.getRuntime().exec(new String[]{"ps", "-ef"});
  23.             exec.waitFor();
  24.  
  25.             BufferedReader reader
  26.                     = new BufferedReader(new InputStreamReader(exec.getInputStream()));
  27.  
  28.             String line = "";
  29.             while ((line = reader.readLine()) != null) {
  30.                 if (line.contains("sqldeveloper.conf")) {
  31.                     System.out.println(line);
  32.                     String[] split = line.split(" ");
  33.                     if (split.length > 2) {
  34.                         System.out.println(split[1]);
  35.                         if (!split[1].equals("")) {
  36.                             Process execKill = Runtime.getRuntime().exec(new String[]{"kill", "-9", split[1]});
  37.                             execKill.waitFor();
  38.                         } else {
  39.                             Process execKill = Runtime.getRuntime().exec(new String[]{"kill", "-9", split[2]});
  40.                             execKill.waitFor();
  41.                         }
  42.                     }
  43.                     break;
  44.                 }
  45.             }
  46.  
  47.         } catch (Exception e) {
  48.             System.out.println(e.getMessage());
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement