Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to iterate a package?

 
Ning Du
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I need to investigate every class in certain a package. How can I get all the classses in a package?

Any reply will be appreciated!!
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally, you can't, as far as I know.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can iterate classes in a jar or a directory pretty easily, but that won't necessarily get you every class in a package because multiple jars or file systems could contain classes with the same package path.
 
Ning Du
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody knows about how the code assist is implemented in Eclipse? As you know, when you type a package name in Java editor and type "." , after a while all the classes in this package will be listed.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way or another in Eclipse you have set a classpath to a bunch of jars and directories. I'd bet it iterates those to see what's out there. It knows what is in your open projects, too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic