This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes unix commands thru java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "unix commands thru java program" Watch "unix commands thru java program" New topic
Author

unix commands thru java program

Bhasker Reddy
Ranch Hand

Joined: Jun 13, 2000
Posts: 176
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


Bhasker Reddy
Kripal Singh
Ranch Hand

Joined: Jul 26, 2001
Posts: 254
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());
}


# Help an unprivileged kid.<br /> Whatever u do will make a difference...<br /> ...to a child's life & ur own #<br /><a href="http://www.cry.org/" target="_blank" rel="nofollow">www.cry.org/</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unix commands thru java program