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 Beginning Java and the fly likes Process and Runtime Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Process and Runtime Class" Watch "Process and Runtime Class" New topic

Process and Runtime Class

Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385

I was just studying about Process and Runtime class and tried few example and got struck with the below problem.

I am trying to call another java program using differnt JDK by apssing argument.

But the problem is when the argument contain spaces i put them inside the " but still it consider them as two arguments.

Please help.

After running this code the length of argument is 2 instead of 1.

When i display the passed arguments in another class,it is showing as two arguments namely "Test and Sample" instead of Test Sample.


Failure is not an option.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Did you try to use java.lang.Runtime#exec(java.lang.String[]) instead ?

[My Blog]
All roads lead to JavaRanch
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385

That helped me.
Thanks a lot
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43935
Make sure to read the article by Michael Daconta called "when Runtime.exec() won't" before using Runtime.exec().
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Process and Runtime Class
It's not a secret anymore!