Hello everyone,
I'm having a problem when I try to display my applet online.
I can view the applet on my desktop, with .htm file. However, when I upload the same file, along with the required .class files, I get the following error while viewing the applet online:
java.lang.ClassFormatError: Extra bytes at the end of class file Login
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.ClassFormatError: Extra bytes at the end of class file Login
Please help me out with this. When I googled the problem, I found that such exceptions are thrown with older versions of java. But my version of java is latest. I'm using Java build 1.6.0_18-b07.
These are actually the steps involved in getting the .class file:
1. I first create the applet in netbeans 6.8
2. After that, I build the project.
3. I take the .class files ( Login.class, Login$1.class, Login$2.class) and copy it to a seperate folder. In the same folder, I create a small html file having <html><body> tags, and then add the applet tage as follows:
<applet code="Login.class" width=... height=...></applet>
The applet works perfectly well when I open the newly created html file. After I upload the html and .class files, I get the above error while viewing them. I am still able to view the one on the desktop.
Where am I going wrong here?