This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes As a command it runs fine from cmd prompt but not from java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "As a command it runs fine from cmd prompt but not from java code" Watch "As a command it runs fine from cmd prompt but not from java code" New topic
Author

As a command it runs fine from cmd prompt but not from java code

sahana mithra
Ranch Hand

Joined: Oct 26, 2010
Posts: 72
The code given below actually tries running a command. This command when run from command prompt, produces the necessary output. But when i try to run the application from java code, it keeps on running and doesn't produce any output file.



Thanks
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1508
    
    5

From a single command prompt can you execute three executable files at the same time, probably no. You have to execute one at a time. So you probably code should look somewhat like this.



Swastik
sahana mithra
Ranch Hand

Joined: Oct 26, 2010
Posts: 72
hi,
The format is not as i have given. I have just shown a sample. It l be like arg[0]+cnst[1]+cnst[2]+arg[1]+cnst[3]+cnst[4]+cnst[5]+arg[2]. Any other way to do this???
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12998
    
    5
Very common problem - carefully read the JavaDocs for java.lang.Process - take note of the part about the necessity of consuming the stdout, and sterr streams.

A search for "java exec process problem" will find more help.

Bill
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: As a command it runs fine from cmd prompt but not from java code
 
It's not a secret anymore!