Solved

Applet and ClassLoader

Posted on 1997-08-22
1
323 Views
Last Modified: 2013-12-29
Is it possible to create an Applet which could load and execute Applets from another URL? I know about showDocument-method, but I would like to execute Applets in my own Applet's Frames. Is it possible to use some kind of ClassLoader class to do this?
0
Comment
Question by:Klaavu
1 Comment
 
LVL 4

Accepted Solution

by:
russgold earned 150 total points
ID: 1225621
Only partially possible. You may load and execute another Applet as long as the other Applet is available in your applet's CLASSPATH.  Applet's are subclasses of containers, and may be treated as such.  Note that you cannot use a URL to do this, since URLs specify pages, not applets.

The problem is twofold. You can only access files of any kind - even via URL - if they come from your applet's home site.  But even then, your non-overridable ClassLoader is restricted to the CLASSPATH specified in your HTML <APPLET> tag.

Here is some sample code that works if you meet all the necessary conditions:

try {
    Class appletClass = Class. forName( "AnotherApplet" );
    Object anotherApplet = appletClass. newInstance();
    if (anotherApplet instanceof Applet) {
        appletContainer. add( anotherApplet );
        anotherApplet. init();
        anotherApplet. start();
        }
    }
catch( Throwable t ) {
    // handle ClassNotFoundException, InstantiationException,
    // and IllegalAccessException
    }

you will have to make sure that the applet's start() and stop() methods are called at the appropriate time.

Note: this
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cipher Configuration on Apache HTTPD 4 53
how to add new optional parameter to JSP 1 29
servlet example issue 6 32
hibernate jars 4 4
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now