#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Java Applet - Blank Page - NoClassDefFoundError??????


    In my java console I have the following exception...


    Exception in thread "thread applet-MyAppletForm.class-3" java.lang.NoClassDefFoundError: MyAppletForm$1
    at MyAppletForm.init(MyAppletForm.java:47)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


    Here is my code ...

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */


    /**
    *
    * @author User
    */
    public class MyAppletForm extends javax.swing.JApplet {

    /**
    * Initializes the applet MyAppletForm
    */
    @Override
    public void init() {



    /*
    * Create and display the applet
    */
    try {
    java.awt.EventQueue.invokeAndWait(new Runnable() {

    public void run() {
    initComponents();
    }
    });
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    }




    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:

    jLabel1.setText("clicked");


    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration
    }

    ---------------------------------------------------

    I'm using Apache - XAMPP as my server

    Would like to have help with the error message. I have the class file copied to my web folder in htdocs in xampp. Here is the HTML code for my simple website .....

    <Html>
    <Head>
    <Title>Java Example</Title>
    </Head>

    <Body>
    This is my page<br>
    Below you see an applet<br>
    <br>
    <Applet Code=MyAppletForm.class width=800 Height=500>
    </Applet>
    </Body>
    </Html>
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    java.lang.NoClassDefFoundError: MyAppletForm$1
    The program could not find the class named in the error message. It's an anonymous internal class (the $1 in the name) probably from the new Runnable() statement.
    Are all the .class files together? If you copied them, make sure you got all of them.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Yes, but still nothing


    Yes there there.
    My web page is blank.

    The files...

    MyAppletForm$1.class
    MyAppletForm$2.class
    MyAppletForm.class

    are in my web folder and were copied from my project folder.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Assuming


    I'm only assuming that these files are being generated at compiletime by netbeans.

    MyAppletForm$1.class
    MyAppletForm$2.class
  8. #5
  9. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    If the html file and the class files are all in the same folder, I think the program would find the class files it needs. Are the html and class files all in the same folder?
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    My solution ...


    Works now. Basically I just restarted my apache server. Success. I now created my first applet.

    -----------------------------

    Between you and me let me I would like to make myself available for any programming projects that come your way.

IMN logo majestic logo threadwatch logo seochat tools logo