GeeCON Prague 2014*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes incorrect command line parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "incorrect command line parameters" Watch "incorrect command line parameters" New topic
Author

incorrect command line parameters

Mike Hays
Greenhorn

Joined: May 15, 2009
Posts: 14
Hey All,

What's the best way to handle errors cause by incorrect command line parameters? I was displaying a usage note in the console and exiting the application. I changed it to display a dialog with an error message describing the problem. In this case, the application exits after the dialog is dismissed. The problem with this is that there is no frame. If the dialog gets behind another window the user may not know that it is there.

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5300
    
  13

Hi Mike,

I just wrote a message to System.err indicating the allowed command line parameters.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Mike Hays
Greenhorn

Joined: May 15, 2009
Posts: 14
OK. What do you think about throwing an exception from main()? I'm considering throwing an IllegalArgumentException and not catching it in the main() method. A stack trace would appear in the console with the usage note. I wonder if this is not considered a good approach.

I don't think this is a big issue either way. Just trying to clean up some little things. Thanks.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5300
    
  13

I think the stack trace may confuse a user who is not so familiar with Java.
zhan dan
Greenhorn

Joined: Jun 26, 2010
Posts: 1
writing a message to System.err indicating the allowed command line parameters. That's a good way.


Cheap ghd straighteners helps every beauty conscious in achieving their dream appearance! More information about fashion and beauty from ghd blog
 
Consider Paul's rocket mass heater.
 
subject: incorrect command line parameters