The Artima Developer Community
Sponsored Link

Java Answers Forum
Help : How can I reload a file .class ???

1 reply on 1 page. Most recent reply: Jun 7, 2003 8:56 AM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
guillaume

Posts: 21
Nickname: salulezami
Registered: May, 2003

Help : How can I reload a file .class ??? Posted: Jun 6, 2003 2:38 AM
Reply to this message Reply
Advertisement
Hello friends,
I need to reload a file .class in a java application cause I rebuilt the file .java in this same application, and I want the modifications are validate.
THANKS A LOT.
salulezami


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Help : How can I reload a file .class ??? Posted: Jun 7, 2003 8:56 AM
Reply to this message Reply
The following snippet loads an applet class.

    public Applet getApplet(){
        Applet applet = null;
        if ((appletClassName != null) && (appletClassName.length() > 0)){
            ClassLoader loader = ClassLoader.getSystemClassLoader();
            try{
                if (debug) System.out.println("Loading " + appletClassName);
                Class appletClass = loader.loadClass(appletClassName);
                if (debug) System.out.println(appletClass.toString());
                Object object = appletClass.newInstance();
                /* Checks to make sure its an applet class. */
                if (object instanceof java.applet.Applet) {
                    applet = (Applet)object;
                    if (debug) System.out.println("Applet: " + appletClassName + " loaded.");
                }else{
                    System.err.println("Class was not an Applet.");                 
 
                }
            }catch(IllegalAccessException iae){
                System.err.println("IllegalAccessException: " + iae.getMessage());
            }catch(InstantiationException ie){
                System.err.println("Class loaded was not an Applet.");
            }catch(ClassNotFoundException cnfe){
                System.err.println("Applet Class not found.");           
            }
        }else{
            if (debug) System.out.println("No Applet specified.");
        }
        return applet;
    }

Flat View: This topic has 1 reply on 1 page
Topic: Interview Questions Previous Topic   Next Topic Topic: Searching Java editors implemented in java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use