views:

941

answers:

2

I am writing a Java applet and embedding it in a web page. It used to run Mac and Windows in different browsers without problem. I was using NetBeans on the Mac to build the .jar file the applet used.

For some reason or another I decided to load the project on the Windows' NetBeans - I started getting the following error on the Windows machine when accessing the web page from any browser:

java.lang.ClassFormatError: Incompatible magic value 1008813135 in class file

Fearing that it must have been my decision to open the project on Windows that caused this error - I tried to build from the Mac's NetBeans - but the error persisted.

I started a while new project on the Mac and imported the existing source code: still same problem.

I was doing some reading about this error and it seems that the magic number expected is 0xCAFEBABE in hex which is 3405691582 in decimal, not 1008813135. So it looks like the Mac version of Java doesn't produce this file header any more? Hoe can that be? I didn't do any updates or anything.

+1  A: 

I have not experienced this problem, but Googling this error yields several possible solutions:

forum.sun.com - Java Applet Development - Incompatible magic value 1008813135 in class file MyApplet

Thanks God the problem is solved.

Its the Java cache, so the solution go to Java Control Panel, "General" tab, and under "Temporary Internet Files" click "Settings", then click "Delete Files". Try using the applet again.

"Incompatible magic value 1008813135" Error?

The problem is now solved: I found out that the website host I was using didn't support .jar files at all. I mass-uploaded the files with my ftp program and didn't notice that it ignored the .jar files completely.

Errors on java initialization

Alright, so it was an apache configuration issue, removed this line from my httpd.conf file:

# DefaultType application/x-httpd-php

Fixed the issue.

polygenelubricants
I think the Java cache would be the theory to blame.The .jar support or apache config wouldn't make much sense because I am serving my web page from the ~/Sites folder on the Mac - and I changed nothing.
Warlax
+5  A: 

Yes, 0xCAFEBABE is the usual first 4 bytes of a Java file.

1008813135 is <!DO in Latin encoding, which is, in all probability, the start of <!DOCTYPE....

It is therefore likely the start of a 404 error, or some other error page.

Pool
+1 - Good theory!
Stephen C
Yeah, I found other reports of this error and it seems to have to do with invalid host configuration, possibly with respect to `.jar` files.
polygenelubricants
So what do I do about that?
Warlax
@Warlax I'd first attempt to load the applet jar file directly. If this works then it's possible you may have an incorrect path to the Jar file. View the server logs to see what URL the Jar file is attempted to be retrieve from.
Pool