Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classes in a package

 
Giri Thava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the command (to be used in DOS) to see what classes are available in a particular package, for instance, assume I want to see what classes are stored in java.util package. What is the command I should use?

javap java.lang.String just displays the methods and variables.

Advance thanks.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49405
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you looking in a .jar? You know that any program which inflates a .zip file will inflate a .jar too; they use virtually the same format? When you have inflated the .jar into folders, use, "cd java, cd util, dir."

You can also find the details of the classes from the standard Java API documentation. Find the overview page with frames, and click on the nams of the package at the top left.

[edit]Corrected anme of package[/edit]
[ February 02, 2008: Message edited by: Campbell Ritchie ]
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is impossible to find out all the classes that could possibly be loaded, in a given package, as ClassLoaders do not have to provide enumeration facilities. Also, of course, additional ClassLoaders can be activated at any time, potentially making more classes available.

The above restriction makes sense, if you think about it, but more surprising to me is that you can't easily list all the loaded classes, either. (Or can you?).

If you know all your classes will be loaded by the system ClassLoader, then you can examine the classpath (it's a system property) and then read the directories and Jars to find all the classes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic