In my Java project I need to list all class names in the current package, I usually run my app in two different modes : <1> From NetBeans, <2> From an executable jar file packaged by the NetBeans.
My question is : How to write my program so that no matter which mode it is running, it can list all the class names in my app. Because when I run it in the NetBeans mode I can look into the src/ directory to list the class names, but when run in the packaged executable jar file mode on another machine, the src/ dir isn't there, so if in my program I try to list jar entries and find the class names that way, it won't work when run in NetBeans, because it isn't jared yet.
I know I can try to detect which mode it is running under and handle differently, but is there a better way to do it without knowing which mode it is running under ?
I wonder if the following approach would solve my problem :
http://snippets.dzone.com/posts/show/4831
I tried : getClasses(".") to get current package's classes, it didn't work, why ?
Frank