Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Applet and ClassLoader

Posted on 1997-08-22
1
325 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

808 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