This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get the list of packages, classes in packages and methods in class

 
Serkan Demir
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I am working on a code generation project with Velocity. In order to use as parameters, I have to get the list of packages, classes in packages and methods in classes and put them into different array lists.
Is there any built-in libraries or java methods for these operation?

thanks lot,

Serkan
 
Satish SN
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U can get the Information from java.lang.Class
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.Class can, indeed, tell you the methods in a class; but the only way to get a list of packages or a list of classes in a package is by examining the class path and searching for .class files both in and out of JAR files along that class path. This is a bit easier if you can limit the scope of your query to the classes loaded by a custom classloader that you created yourself, so you know exactly where it's searching.

This is not even close to a "Beginner" topic, so I'm going to move this to Java in General (Intermediate).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic