File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes Applet jar will not load.  Peculiar. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet jar will not load.  Peculiar." Watch "Applet jar will not load.  Peculiar." New topic

Applet jar will not load. Peculiar.

Bill Clar
Ranch Hand

Joined: Sep 21, 2006
Posts: 163

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:


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.


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).
Bill Clar
Ranch Hand

Joined: Sep 21, 2006
Posts: 163

Got it working. Took some trial and error though.

1) I simplified things even further by borrowing Oracle's simple "Hello World" Applet. This jar file contain only the .class file and no subdirectories.

Running this applet resulted in the same error.

2) Another google page (sorry, don't have the link) said that applets need to be publicly accessible by the browser. THIS is my culprit.

My /civil/applet folder on my Tomcat webapp was not public. It was restricted by default and I never thought about it's permissions. Giving it public access resulted in a happy "Hello World" applet.

Problem solved.

Darryl Burke

Joined: May 03, 2008
Posts: 5115

Thank you for posting the solution.

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link:
subject: Applet jar will not load. Peculiar.
It's not a secret anymore!