Re: [Ikvm-developers] dynamic class loading question
Brought to you by:
jfrijters
|
From: Jeroen F. <je...@su...> - 2006-08-23 15:35:59
|
Hi, You can only do that with reflection and by explicitly instantiating a class loader. Here's an example that runs ecj from the jar: using java.net; using java.io; using java.lang; using java.lang.reflect; public class Example { static void Main(string[] args) { URLClassLoader loader =3D new URLClassLoader(new URL[] { new File("c:\\temp\\ecj-3.2.jar").toURL() }); Class c =3D Class.forName("org.eclipse.jdt.internal.compiler.batch.Main", true, loader); Method m =3D c.getMethod("main", new Class[] { typeof(string[]) }); m.invoke(null, new object[] { new string[0] }); } } Regards, Jeroen > -----Original Message----- > From: ikv...@li...=20 > [mailto:ikv...@li...] On=20 > Behalf Of Wolf Christian > Sent: Wednesday, August 23, 2006 17:04 > To: ikv...@li... > Subject: [Ikvm-developers] dynamic class loading question >=20 > Hello, >=20 > =20 >=20 > One question to see if it's possible or not: >=20 > =20 >=20 > It's like the A.exe, B.dll, C.dll example on the Concepts=20 > page of the IKVM website (class loading concept).=20 >=20 > But in my case it's A.exe, B.dll and C.jar. A knows B. B=20 > creates an instance of a class presents in C.jar. (And this jar is=20 >=20 > Present in the classpath) >=20 > =20 >=20 > For the moment I always had a Class not found exception.=20 >=20 > =20 >=20 > So..Is there a way to make it works? Or.I have to forget this idea?=20 >=20 > =20 >=20 > Thanks in advance >=20 > =20 >=20 > Christian >=20 >=20 |