This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I frequent these forums for research and I strive not to take advantage with questions that can be answered with a little research. Unfortunately, I'm at an impasse and could benefit from any knowledge you have.
I'm building my first JApplet, and it unsuccessfully loads with the inevitable "Incompatible magic value 171733859".
Paul Clapham wrote:No, it's clear that the browser's Java support is finding your class file just fine... it's complaining about its contents.
The "magic number" it's complaining about is the first four bytes of the class file. Those bytes are supposed to contain a specific set of values (actually "CAFEBABE" in hexadecimal), but they don't. What you see in the error message is the decimal value of the magic number; 1008813135 decimal is equal to 3C21444F in hexadecimal.
And when you look at an ASCII table, you can see that 3C21444F hexadecimal corresponds to the four characters "<!DO". And that suggests to me that what the browser is downloading from your so-called "class" file is actually some kind of XML or HTML document which starts with a DOCTYPE. So put your actual compiled class file there instead.>
I translated my magic number, 171733859, to hexadecimal, 0a:3c:73:63, to ASCII, "?<sc". To the best of my knowledge, I do not have any document, xml or otherwise, in my webapps directory that starts with "?<sc". To verify, I ran 'grep -r "?<sc" *' and it returned nada.
2) I focused on a working applet, to eliminate the possibility that my applet is in error. I deferred to Java's twirling mascot applet. This applet loads and runs from Oracle's URL without any problem.
I downloaded the applet's jar and placed it in my webapps directory. I also borrowed Oracle's applet tag and placed it in TumbleItem.html:
NOTE: I do not have a directory for images/tumble. I didn't feel it was necessary as parameters shouldn't prevent an Applet from loading.
3) In my Tomcat webapps, I created the subdirectory "civil/applet" and stored TumbleItem.jar and TumbleItem.html.
4) Here is the Java 1.6.0_31 Console Log:
I'm particularly interested in this snippet:
The URL is correct and verified. I can go to URL "http://vesta:10074/civil/applet/TumbleItem.jar" and I will be prompted to save the jar file. The file size of the downloaded JAR matches that of the one on my server.
The Content-Length is not correct. The TumbleItem JAR is approximately 59K.
5) I verified the permissions on my webapps directory with a simple test. I put a GIF file in my civil/applet subdirectory to see if I can pull it up in my browser. It worked.