JDK1.1 allows ClassLoader in Applet.

Lee Stephens (lee@info.bt.co.uk)
Thu, 19 Dec 1996 08:38:53 +0000

Date: Thu, 19 Dec 1996 08:38:53 +0000
From: Lee Stephens <lee@info.bt.co.uk>
Subject: JDK1.1 allows ClassLoader in Applet.

--------------48FB238460F6
Content-Type: text/plain; charset="us-ascii"
X-Sun-Content-Length: 334

Dear All,

would I be correct in assuming this is not allowed?

My applet is using a ClassLoader to load another applet.

getClass().getClassLoader().loadClass(X);

Works with JDK1.1

Lee

------------------------------------
Lee M J Stephens - lee@info.bt.co.uk
BT Laboratories - (01473) 605531
------------------------------------

--------------48FB238460F6
Content-Type: text/plain; charset="us-ascii"; name="appvapp.java"
Content-Disposition: inline; filename="appvapp.java"
X-Sun-Content-Length: 496

import java.awt.*;
import java.applet.Applet;

public class appvapp extends Applet {
Applet hw;

public void init() {
Frame frame = new Frame("AppletV");
frame.resize(300, 200);
hw = null;
try {
ClassLoader classLoader = getClass().getClassLoader();
hw = (Applet)classLoader.loadClass("hw").newInstance();
} catch (Exception e) {
System.err.println(e);
}
if (hw != null) {
hw.init();
frame.add(hw);
}
frame.show();
}

public void start() {
hw.start();
}
}

--------------48FB238460F6
Content-Type: text/plain; charset="us-ascii"; name="hw.java"
Content-Disposition: inline; filename="hw.java"
X-Sun-Content-Length: 154

import java.applet.*;
import java.awt.*;

public class hw extends Applet {

public void paint(Graphics g) {
g.drawString("Hello, World", 25, 25);
}
}

--------------48FB238460F6--