🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14892

Re: Obtaining the package.

#14892
From: Hugo Ferreira
Date: Mon, 26 Jul 1999 00:00
41 lines
1941 bytes
Tor,

>You _need_ the package name in order to get a Class: They don't exist
>runtime without a fully qualified name.

Too true. In fact, my first attempt was:

1. Use a specific class.
2. Get the package to which it belongs.
3. Finally load the rest of the classes within this package (to ensure it's
the correct version).

I realized that Class  clss  = AClass.class; works. Because the first
specific class was a
"Factory", I had to load classes via theire name, hence the use of
Class.forName( "xxx" );

Now, if only I can remember why I made such a fuss in the first place 8-].

Thanx for your help Tor.

Hugo.


Tor Iver Wilhelmsen wrote in message ...
>"Hugo Ferreira" <HugoF@cocaina.inescn.pt> writes:
>
>> My problem is:
>> Given only the class name and not the full path via a string, how can I
get
>> the Class ?
>
>You _need_ the package name in order to get a Class: They don't exist
>runtime without a fully qualified name. Java source lets you use
>shortened names (via import) in your source, but they en up fully
>qualified in the .class file.
>
>If you do not know the package name, you cannot get the class. If you
>know _something_ about the package: For instance, "it's the same
>package as this class", then you can use the substring method and
>append ".ClassName" before calling Class.forName().
Technical Details
Message-ID: <7nh2jr$2164@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7n700i$mdu1@forums.borland.com> <uemi06gtg.fsf@sds.no> <7n74vv$mdu8@forums.borland.com> <un1wn4ye8.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/26
Message-ID: <7nh2jr$2164@forums.borland.com>
X-Deja-AN: 505296846
References: <7n700i$mdu1@forums.borland.com> <uemi06gtg.fsf@sds.no> <7n74vv$mdu8@forums.borland.com> <un1wn4ye8.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