-
My simple applet won't run
This problem has been solved.
The error:
java.lang.ClassFormatError: Extra bytes at the end of class file
Was caused by uploading the .class file in ascii format.
I'm new to applets so hopefully my problem will be obvious to someone:
I'm running windows XP, java 1.5.0_05
I have a file called HelloWorld.java-
import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Hello world!", 50, 25);
}
}
[eof]
I run this through javac to get HelloWorld.class
HelloWorld.class is uploaded to the same webpage in the same folder as index.htm-
<html>
<head>
...
</head>
<body>
...
<APPLET CODE="HelloWorld.class" WIDTH=600 HEIGHT=450>
</APPLET>
...
</body>
</html>
The page comes up, loads java, then displays the big X. It's located on geocities, but I'm told that shouldn't be a problem.
I opened the java console and it gives me a rather long list:
java.lang.ClassFormatError: Extra bytes at the end of class file HelloWorld
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-137" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-HelloWorld.class" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Last edited by coffeebreak; 11-12-2005 at 03:45 PM.
-
I'm not sure about this exception. Could you post the URL where your applet is hosted?
Happiness is good health and a bad memory.
-
-
Thanks Joe Beam, that was the problem. Note for others: the problem was uploading the .class file in ascii format.
Geocities only allows ascii uploading, no ftp, so I guess I'd better find a better site.
-
Hi..did u find any site that supports ftp upload ..do let me know..thanx
Similar Threads
-
By Manticor in forum Java
Replies: 2
Last Post: 05-29-2005, 01:27 AM
-
By crash75uk in forum Java
Replies: 1
Last Post: 04-20-2005, 03:32 PM
-
Replies: 0
Last Post: 03-30-2003, 01:57 AM
-
By Dave Brown in forum Enterprise
Replies: 0
Last Post: 08-25-2001, 02:51 PM
-
By Charlie Flynn in forum Java
Replies: 3
Last Post: 08-23-2001, 11:01 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|