• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unix commands thru java program

 
Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we issue unix commands thru java program.
I am writing a java file, i have shell program. I need to
issue those directives to the unix system thru java program
can i do that.
does anyone has any idea regarding this.
if i am not clear enough please let me know
thanks
 
Kripal Singh
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can execute your command using following code
Runtime rt = Runtime.getRuntime();
try{
Process ps = rt.exec(your command here);

}
catch(Exception e)
{
System.out.print(e.getMessage());
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic