wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 24183
    
  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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Basic Reflection Problem
 
Similar Threads
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Layout
Need a little help...
Question on Classpaths
Querying class information
Test Classes - newbie question