This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Classes in a package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Classes in a package" Watch "Classes in a package" New topic
Author

Classes in a package

Giri Thava
Ranch Hand

Joined: Jun 22, 2006
Posts: 38
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

Joined: Oct 13, 2005
Posts: 38517
    
  23
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

Joined: Oct 30, 2001
Posts: 1970
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.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Classes in a package