The moose likes Java in General and the fly likes code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "code" Watch "code" New topic


Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 265
can any body know how to rereive java packages in classpath through java program !!!
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
You can not do it in a general case.
If you happen to know you have a directory-based CLASSPATH (not url as in applets or whatever), you can do a file search. You have to look thru each entry in java.class.path and search in there. If the entry is a jar, you will have to crack it open to look.
I wrote a command-line program to search for classes, you are welcome to try it.
In the more general case, you will have a ClassLoader that will not tell you (thru the ClassLoader API) where it is getting classes from. So there is no way to do a search without knowing the class names.
Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 265
Thanks Dave ....
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
How DO you pronounce that first name

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: code
It's not a secret anymore!