It would be nice instead of printing the stack trace we tell the user what was wrong with the arguments. We can do this by adding the following instead of stacktrace.
System.out.println("Argument Error: " + e.getMessage());
HelpFormatter f = new HelpFormatter();
f.printHelp("OptionsTip", opt);
//e.printStackTrace();
Discussion on:
View:
Show:
I use the PosixParser and it leaves a lot to be desired, but I haven't had time to fix much.
I had to override the HelpFormatter class because for some stupid reason the arguments are not listed in addition or alphabetical order; I hate unsorted lists, there is no excuse!
I addition this API is too inflexible e.g. for the Posix Parser, you must have a character arg to have a named arg and can only address arguments by the character arg, this becomes very annoying when you run low on spare characters e.g. GNU C apps do not have this limitations! If time I will see if this can fixed too.
I had to override the HelpFormatter class because for some stupid reason the arguments are not listed in addition or alphabetical order; I hate unsorted lists, there is no excuse!
I addition this API is too inflexible e.g. for the Posix Parser, you must have a character arg to have a named arg and can only address arguments by the character arg, this becomes very annoying when you run low on spare characters e.g. GNU C apps do not have this limitations! If time I will see if this can fixed too.
hi,
i am developing a plugin where i need to interact
with command line.i can execute commands but can not
catch anything that the respective process is throwing on the console.
is there any way to interact with commandline through java?
thanks,
Vrush
i am developing a plugin where i need to interact
with command line.i can execute commands but can not
catch anything that the respective process is throwing on the console.
is there any way to interact with commandline through java?
thanks,
Vrush
If you whant to catch what the console is throwing, you must use a java.io.InputSream that will read what the console is throwing
Like this:
Process proc=Runtime.exec(...);
InputStream in= proc.getInputStream();
int j;
while ((j = out.read()) != -1)
/* j represents each character that the console is throwing, only you need to do is to cast j to char - (char)j and...*/
Like this:
Process proc=Runtime.exec(...);
InputStream in= proc.getInputStream();
int j;
while ((j = out.read()) != -1)
/* j represents each character that the console is throwing, only you need to do is to cast j to char - (char)j and...*/
Please look at the URL below ( It has detailed answer for your query)
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
In brief, use "Process" class to get the Output of exec().
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
In brief, use "Process" class to get the Output of exec().
The parse methods of CommandLineParser are used to parse the command line arguments. hire a programmers
- Keyboard Shortcuts:
- Prev
- Next
- Toggle









































