Article View: borland.public.jbuilder.java.api
Article #112Re: Importing User Defined Classes
From: Peter Th�nell
Date: Mon, 12 Apr 2004 03:09
Date: Mon, 12 Apr 2004 03:09
18 lines
1403 bytes
1403 bytes
Do you mean you want to load .class files at runtime and then run them? If
so, then...
1. Extend ClassLoader and add a method such as:
public Class bytesToClass(String string, byte[] bytes, int offset, int
length)
{
return defineClass(string, bytes, offset, length);
}
2. Load the .class file into a byte array and call bytesToClass(), which
will return you a Class object.
3. Use the Class object to create new instances of that class.
Hope that helps.
Technical Details
Message-ID:
<407a0851$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed.iinet.net.au!newsfeed.iinet.net.au!PeerFeed.KWeb.on.ca!news.kweb.on.ca!newsgroups.borland.com!not-for-mailReferences:
<406c5af8$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,3989b6fd8fa4baf5 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2004-04-11 20:20:13 PST From: "Peter Th�nell" <thonellp@optusnet.com.au> Newsgroups: borland.public.jbuilder.java.api References: <406c5af8$1@newsgroups.borland.com> Subject: Re: Importing User Defined Classes Date: Mon, 12 Apr 2004 11:09:10 +0800 Lines: 20 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 198.142.111.14 Message-ID: <407a0851$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1081739345 198.142.111.14 (11 Apr 2004 20:09:05 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed.iinet.net.au!newsfeed.iinet.net.au!PeerFeed.KWeb.on.ca!news.kweb.on.ca!newsgroups.borland.com!not-for-mail