title: How to list all class names in the current package with Java?
body: <p>In my Java project I need to list all class names in the current package, I usually run my app in two different modes : &lt;1> From NetBeans, &lt;2> From an executable jar file packaged by the NetBeans.</p>
  
  <p>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.</p>
  
  <p>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 ?</p>
  
  <hr>
  
  <p>I wonder if the following approach would solve my problem :</p>
  
  <p><a href="http://snippets.dzone.com/posts/show/4831" rel="nofollow noreferrer">http://snippets.dzone.com/posts/show/4831</a></p>
  
  <p>I tried : getClasses(".") to get current package's classes, it didn't work, why ?</p>
  
  <p>Frank</p>