• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

incorrect command line parameters

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike,

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

Kind regards,
Roel
 
Mike Hays
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the stack trace may confuse a user who is not so familiar with Java.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
writing a message to System.err indicating the allowed command line parameters. That's a good way.
 
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic