File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Basic Reflection Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Basic Reflection Problem" Watch "Basic Reflection Problem" New topic
Author

Basic Reflection Problem

Sashi Gundoji
Greenhorn

Joined: Jan 30, 2007
Posts: 10
Hi all,

I am new to Java and I am having basic question about reflection.

I am having one main package and under main package I have several other package. See below example.

I need to search from main package to find all test files and get all variables of test files.

I need to search the whole main package.

Is it a good idea to use reflection or some other way. If reflection is good, then I would like to know how can I get all packages references by using reflection.

Example:

MainPackage
SubPackage1
subsubpackage11
test1.java
SubPackage2
test2.java
SubPackage3
subsubpackage31
test3.java


thanking you,

Regards,
Dimpu
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

There are no reflection calls to get a list of all packages, or a list of all classes in a package, because both of these are potentially unlimited lists. If this is a development environment and you're looking at class files laid out on disk, just use java.io.File to look at them. If the classes are in JAR files, then use the java.util.jar.JarFile class directly.


[Jess in Action][AskingGoodQuestions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Basic Reflection Problem