Article View: borland.public.jbuilder.java.language
Article #14985Re: Obtaining the package.
From: Hugo Ferreira
Date: Thu, 22 Jul 1999 00:00
Date: Thu, 22 Jul 1999 00:00
33 lines
1460 bytes
1460 bytes
Tor,
>Do you want the package _name_ or the Package _object_? The former is
>easy:
>
>String package = ""; // Default package - empty
>String className = someObject.getClass().getName();
>int p = className.lastIndexOf('.');
>if (p > -1)
> package = className.substring(0, p);
Actually I want the Class object.
The problem is that if I use the following code:
Class Iclss = Class.forName( fullInterfaceName );
then "fullInterfaceName" must be the complete class name ex.:
packageName.sub-packageName.classname
If I use the code below it works because the JVM already knows where the
class AClass exists.
Class clss = AClass.class;
Class.forName( clss.getName() );
My problem is:
Given only the class name and not the full path via a string, how can I get
the Class ?
Naturally I tried the Package, but the classes loader's getPackage() just
returns null !
TIA.
Hugo Ferreira.
Technical Details
Message-ID:
<7n74vv$mdu8@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7n700i$mdu1@forums.borland.com> <uemi06gtg.fsf@sds.no>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,1795c29638346898 X-Google-Attributes: gidf74b3,public From: "Hugo Ferreira" <HugoF@cocaina.inescn.pt> Subject: Re: Obtaining the package. Date: 1999/07/22 Message-ID: <7n74vv$mdu8@forums.borland.com> X-Deja-AN: 503997910 References: <7n700i$mdu1@forums.borland.com> <uemi06gtg.fsf@sds.no> Organization: Another Netscape Collabra Server User X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 Newsgroups: borland.public.jbuilder.java.language