• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

finding packages  RSS feed

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to list all the packages in my class path using a java program?


for eg. if the class path is c:\ajay;
and ajay contains two folders pack1(i.e a package) and pack2(i.e a general folder not a package)

in pack1 there are 2 java file which has package pack1; as their first statement.

in pack2 there are two java file which does not contain package statement.

so can i identify between pack1 which is a package and pack2 which is a general folder
 
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both aren't packages, because the class-file has to be in a certain folder, not the java file.
 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i meant class files not java files my mistake

but what i want to know is,how to differentiate between a package and an ordinary folder

what i want to do is to list all the class files in a particular folder(path)say D:\ and i have a package in D:\ called test then i should be able to list all the classes in path which includes test package such as test.Test now how do i know that test is an package and not a folder
[ November 28, 2004: Message edited by: Rajagopal Manohar ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!