Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Using Runtime.getRuntime().exec()



At 1:35 PM -0400 8/22/06, Jha, Navin wrote:

    Guys,

Yes I just verified it. All I did was change from String to String[] and it worked. I guess I could look at the exec() source to see how the too are different.

Thanks,
Navin

What you'll find is that the single-string version of exec() creates a StringTokenizer around your String parameter. That tokenizer uses white space characters as delimiters. Therefore, it will break your command line at each space, tab, new line, return or form feed. It's not good. And Sun also points out in the Javadocs that StringTokenizer is a legacy class that shouldn't be used.


I learned the hard way that it's *always* best to place each portion of your command line into a separate cell of a String array. I also found on Windows that it works best when a parameter refers to a path with spaces if you quote it. Our Macs are much friendlier in this area. :-)

= Steve =
--
Steve W. Jackson
Montgomery, Alabama
http://homepage.mac.com/stevejackson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >RE: Using Runtime.getRuntime().exec() (From: "Jha, Navin" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.