Get your CodeRanch badge!*
The moose likes Beginning Java and the fly likes One  Major Problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "One  Major Problems" Watch "One  Major Problems" New topic
Author

One Major Problems

vishwas bhatt
Ranch Hand

Joined: Nov 30, 2000
Posts: 129

Hi EveryBody There,
How can i get the name of all classes in specified pacakage from java program.
Ex:
I want to get each class from java.io.* how
can to write a programe for this. don't want to use javap like this
Runtime rt = Runtome.getRunTime();
String a[] = String[1];
a[0] = "java.io.*";
rt.exec("javap.exe",a[0]);
I don't want to use this code because this is not a platform independent.
suggest me other Options pls.

[ April 08, 2002: Message edited by: Carl Trusiak ]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
You need to look into using the JarFile class.

public class JarFile
extends ZipFile
The JarFile class is used to read the contents of a JAR file from any file that can be opened with java.io.RandomAccessFile. It extends the class java.util.zip.ZipFile with support for reading an optional Manifest entry. The Manifest can be used to specify meta-information about the JAR file and its entries.


"JavaRanch, where the deer and the Certified play" - David O'Meara
vishwas bhatt
Ranch Hand

Joined: Nov 30, 2000
Posts: 129
Thnaks !
i thought in that same way. but i am not much aware about jar and manifests. according to u i have to extract rt.jar file in runtime of my program (this is what i am getting) am i right..
if it is so then tell me some resorces from whre i can get information about jar file and manifests.
and just tell me don't u think it will decrease speed and performance of my program.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
This is the Sun Jar Tutorial.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
PS:
I have no idea if it will impact the performance of your application. You have not given us a Clue as to what you are doing and why.
Frankly, unless you are writing a utility to manipulate class files, you should not really NEED to look in the Jar files with your program.
But maybe you are writing an IDE or something.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One Major Problems
 
Similar Threads
Question
read data from keyboard
CycleChars
How to validate Url
using the reset() method in InputStream Class