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".
Here's what I've researched, discovered, tested:
1)
https://coderanch.com/t/541772/Applets/java/getting-APPLET-tag-work#2457961
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.
6)
https://coderanch.com/t/480492/Applets/java/Tomcat-JSP-Applet#2155656
Ulf Dittmer wrote:Try removing the codebase attribute.
I removed the codebase attribute. No effect.
7) I cleared my cache in the Java Control Panel. No effect.
So, that's where I am. I'll update this
thread with any new leads, or if I solve the problem (fingers crossed).