Article View: borland.public.jbuilder.java.language
Article #8665Re: Calling applis from an appli
From: John McGrath TeamB
Date: Tue, 06 Mar 2001 11:23
Date: Tue, 06 Mar 2001 11:23
42 lines
2664 bytes
2664 bytes
On Mon, 5 Mar 2001 11:58:12 +0100, icsd.jt@wanadoo.fr wrote:
> Jbuilder Library ? how, with wich file and with wich method?
You configure libraries using the "Configure Libraries" menu from the
tools menu. The help button should lead you to the documentation.
> Same questions with Reflexion API
I cannot possibly tell you all there is to know about the Reflection
API in a newsgroup message, but I can give you an example. Here is a
simple use of the Reflection API to call the main method of a given
class. This is off the top of my head, so you may have to work with it
a bit.
static void callMain( String className, String[] args ) {
// Get the Class object for the specified class.
Class clas = Class.forName( className );
// Get the Method object for the main method.
Class[] mainArgTypes = new Class[] { String[].class };
Method main = clas.getDeclaredMethod( "main", mainArgTypes );
// Invoke the main method with the specified arguments.
Object[] mainArgs = new Object[] { args };
main.invoke( null, mainArgs );
}
I have left out any exception handling, which you will have to add.
There are a *lot* of possible exceptions that can be thrown in this
code, including class or method not found, security exceptions, and
invocation target exceptions (if the main method is found and called,
but throws an exception).
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<MPG.150e84abecca2bdc98a013@forums.borland.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sf.pbi.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!not-for-mailReferences:
<3aa0a077_1@dnews> <MPG.150a9aa7fc92fce5989ffc@forums.borland.com> <3aa10cea$1_2@dnews> <MPG.150b85684df4a28498a003@forums.borland.com> <3aa33b30_1@dnews> <MPG.150d0f0263dfc82d98a00b@forums.borland.com> <3aa3701a$1_2@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,ec6af10449d9afc3 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-03-06 03:26:06 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!cyclone-sf.pbi.net!63.208.208.143!feed2.onemain.com!feed1.onemain.com!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!bornews.borland.com!not-for-mail From: John McGrath [TeamB] <ng-b@JPMcGrath.net> Newsgroups: borland.public.jbuilder.java.language Subject: Re: Calling applis from an appli Date: Tue, 6 Mar 2001 06:23:19 -0500 Organization: Another Netscape Collabra Server User Lines: 42 Message-ID: <MPG.150e84abecca2bdc98a013@forums.borland.com> References: <3aa0a077_1@dnews> <MPG.150a9aa7fc92fce5989ffc@forums.borland.com> <3aa10cea$1_2@dnews> <MPG.150b85684df4a28498a003@forums.borland.com> <3aa33b30_1@dnews> <MPG.150d0f0263dfc82d98a00b@forums.borland.com> <3aa3701a$1_2@dnews> NNTP-Posting-Host: dslcv1-60.fast.net X-Newsreader: MicroPlanet Gravity v2.30