Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Basic Reflection Problem

 
Sashi Gundoji
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic