This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I'd like to use ProcessBuilder to initiate installations of other programs, like Adobe Reader, by reading something in like an ini file which would contain data similar to the following format:
So then my program would read that in (I know how to tokenize everything), and pass that data into a ProcessBuilder object. I've found that putting all of those commands into one "command" when creating a ProcessBuilder object doesn't work. You have to separate each command line argument into a separate ProcessBuilder command (from my experience). Since that's the case, how can I write my program to determine the right number of arguments to pass in and then create that ProcessBuilder object on the fly with an unknown number of command line arguments (at compile-time)? In case anyone is wondering, the only idea I have for now is to have something like a template for creating ProcessBuilder objects that I call based on the number of arguments passed in (and possibly have a limit on the total number of arguments), then call the right method basically based on that number. Isn't there a cleaner solution?
So the ProcessBuilder has two constructors - one that takes a List<String> and one that takes String varargs. I think the problem you are having is related to the use of the varargs version of the constructor. Why not use the List<String> version?
Joined: Jul 11, 2006
You know what? That's a perfect solution! Thanks for the tip! I wonder why I didn't find out about that before... I better read the manual next time.