DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003

    Unhappy Applets not quite working.

    Well what i did here was upload FirstApplet.class into my website there, this is its code:

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

    public class FirstApplet extends Applet
    public void paint(Graphics g)
    g.drawString("I'm told this is everyone's first applet.", 20, 20);

    so i compiled it, uploaded the .class file, and then i entered this here HTML code:


    <title>Main Page for the Testing Site</title>



    <applet code="FirstApplet.class" width=300 height=100>


    and when i preview the page it says "Loading applet failed..." in the status bar. any helps?
    Laxori Shiin.
    Misguided Fool

  2. #2
    Join Date
    Jun 2003


    OH yes, and the Java Console, if i look at it, says:

    java.lang.ClassFormatError: FirstApplet (Extra bytes at the end of the class file)

    at java.lang.ClassLoader.defineClass0(Native Method)

    at java.lang.ClassLoader.defineClass(ClassLoader.java:502)

    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)

    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:148)

    at sun.plugin.security.PluginClassLoader.findClass(PluginClassLoader.java:168)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)

    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:255)

    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:501)

    at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)

    at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1778)

    at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)

    at sun.applet.AppletPanel.run(AppletPanel.java:293)

    at java.lang.Thread.run(Thread.java:536)

    I don't see how i could have extra bytes at the end of my file...=P
    Laxori Shiin.
    Misguided Fool

  3. #3
    Join Date
    Nov 2002
    I compiled your code and it worked, no errors, nothing. Try using the appletviewer, in your command line type: appletviewer page.html, it makes a window for every appelt on that HTML page.
    I like Java!
    Java is cool!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.