Applets not quite working.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Applets not quite working.

  1. #1
    Join Date
    Jun 2003
    Posts
    2

    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:

    <html>
    <head>

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

    </head>

    <body>

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

    </applet>
    </body>
    </html>

    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
    Posts
    2

    None

    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
    Posts
    18
    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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

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