• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Listing packages using Package class

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to list all of the packages using

It listed all the standard packages like java.lang, java.util, etc. When I am trying to list java.rmi, javax.swing or my packages, it’s throwing out NullPointerException.
Can some one throw light on this??
Thanks in advance,
Bala
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The API docs for Package say


Package objects contain version information about the implementation and specification of a Java package.
This versioning information is retrieved and made available by the ClassLoader instance that loaded the
class(es). Typically, it is stored in the manifest that is distributed with the classes.


Did you load any classes from rmi, Swing, or your
own stuff?
Thanks,
Joe
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The API docs for Package say


Package objects contain version information about the implementation and specification of a Java package.
This versioning information is retrieved and made available by the ClassLoader instance that loaded the
class(es). Typically, it is stored in the manifest that is distributed with the classes.


Did you load any classes from rmi, Swing, or your
own stuff?
Thanks,
Joe
 
Bala Raj
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I am loading all the classes.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All of them? Ummm... how are you doing that? Mentioning them in import statements will not be enough to cause them to be loaded - you need to actually use the class somehow. A simple approach might be:

or

We don't really need the name, and aren't even bothering to remember it. This just qualifies as a "use".
 
reply
    Bookmark Topic Watch Topic
  • New Topic