Posts

Showing posts from April, 2014

How to Run Java code in new terminal Through Java Code in Linux

Hi,      Here I have written the snippet for running the java process in new terminal through java code just put your java code name and run simply. import java.io.*; class CodeRunInTerminal {     public static void main(String args[]) throws IOException     {         String command= "/usr/bin/xterm -e java codename";//where the java is command and codename is java code which you want to run in new terminal.         Runtime rt = Runtime.getRuntime();         Process pr = rt.exec(command);     } } Thanks.

How to Kill Java Process in Linux Operating System using Java Code

Java Code for killing the Java process in Linux OS. Hi,     Here I have written the small snippet for killing the java running  process in linux OS. public void checkprocess() {     String s = null;     int x=0;     try     {         Process p = Runtime.getRuntime().exec("jps"); //JPS command is used for showing all the java running process with ID.         BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));         BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));         while ((s = stdInput.readLine()) != null)         {             String[] tokens = s.split(" ");             if(tokens.length!=2)             {                 throw new IllegalArgumentException();             }             String commandid = tokens[0];             String prcess = tokens[1];             System.out.println("Processes  Name is : "+prcesss);             if(prcs.equals("P