Loading
Execute Unix Cmds With java

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  Run Shell Cmds with Java


Ans)

Unix Shell with java Example

This Example illustates how to run the Unix Shell Cmds
with a Java Class.

public class NewTest {

 /**
  * @param args
  */
 public static void main(String[] args) {
  
  System.out.println(" about run");
  String cmd = "sh -c cat /appl/yourImport.fmt /appl/yourImport2.fmt
  > /appl/yourImport3.cvs";
  
  try {
  Runtime runtime = Runtime.getRuntime();
  runtime.exec("ksh -v test.sh");
  runtime.exec(cmd);
  
  System.out.println(" about run 1111");
   String[] args1 =
             new String[]{"sh", "-c", "ls | wc >out2"};

         Process p = runtime.exec(args1);

   System.out.println(" about run 1122");
    String[] args2 =
              new String[]{"sh", "-c", "cat /bin/yourImport1.fmt
     /bin/yourImport2.fmt > /bin/yourImport5.cvs"};

          Process p1 = runtime.exec(args2);
         System.out.println(" about run");
  
  } catch(Exception e) {
   e.printStackTrace();
  }
  
 }

 }



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

Execute Unix Cmds With java


Execute Unix Cmds With java

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free