File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Executing a command-line command from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Executing a command-line command from a servlet" Watch "Executing a command-line command from a servlet" New topic

Executing a command-line command from a servlet

Anirudh Chandrakant

Joined: Mar 23, 2004
Posts: 5

I would like to execute a command-line command from within a servlet. For example, i would like to run "Runtime.getRuntime().exec()".

But, this somehow doesnt get executed. I searched on Google and on these forums but couldn't find any information.

Do i need to do anything to be able to execute this?

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Anirudh Chandrakant:

But, this somehow doesnt get executed.

Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see:

What does happen when you execute your servlet?

Again, welcome to JavaRanch and good luck with your question.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13035
The common problem with exec() - frequently discussed in detail in these forums - has to do with consuming the output streams created by Process created. Read the Javadocs for java.lang.Process.


Joined: Oct 02, 2006
Posts: 17
Runtime.exec() method is used to run the process( exe files).
For example call Runtime.exec("notepad") and see the results.

Even i dont know how to pass arguments to the servlet
David O'Meara

Joined: Mar 06, 2001
Posts: 13459


I counted 6 warnings before I stopped counting. You only get 3.

I'm closing your account, please register with a display name which follows the JavaRanch naming rules.

[ October 25, 2006: Message edited by: David O'Meara ]
I agree. Here's the link:
subject: Executing a command-line command from a servlet
It's not a secret anymore!