Get name of executable jar from within main() method [duplicate]

Here you go: new java.io.File(SomeClassInYourJar.class.getProtectionDomain() .getCodeSource() .getLocation() .getPath()) .getName() Edit: I saw your comment about getSourceCode API. Well, this is probably the best you can do in Java. About getCodeSource() returning null, I think it mainly happens on classes in java.lang.* and other special classes for which the source location is “hidden”. Should work for … Read more

Apache Commons CLI – option type and default value

EDIT: Default values are now supported. See answer https://stackoverflow.com/a/14309108/1082541 below. As Brent Worden already mentioned, default values are not supported. I had issues with using Option.setType too. I always got a null pointer exception when calling getParsedOptionValue on an option with type Integer.class. Because the documentation was not really helpful I looked into the source … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)