28

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.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Warlax
  • 2,459
  • 5
  • 30
  • 41

6 Answers6

62

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
  • 11,999
  • 14
  • 68
  • 78
  • 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 Mar 06 '10 at 00:10
  • @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 Mar 06 '10 at 13:37
  • 1
    1008813135 is an integer? or hex? – Jaime Hablutzel Feb 25 '13 at 16:13
  • The first 4 bytes are read into ints and converted, see http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/java/io/DataInputStream.java#DataInputStream.readInt%28%29 – Pool Dec 04 '13 at 12:42
  • If we have no access to the server, how can we get the full error text to see what the problem is? – SystemParadox Sep 23 '20 at 12:24
6

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.

Community
  • 1
  • 1
polygenelubricants
  • 376,812
  • 128
  • 561
  • 623
  • 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 Mar 06 '10 at 06:34
1

If you are using Spring security or some sort of custom Servlet Filters, make sure, that the archive or codebase location is in "permitAll" access. This was to problem in my case

forest
  • 85
  • 7
0

The incompatible magic number is the first four bytes of a html file that has some error message in it, probably a message that the file isn't found.

I encountered this phenomenon when I didn't take case sensitivity into account in the codebase element of the applet tag. Things worked well on Windows, but the internet server I was using was running UNIX where filename case sensitivity is important. Making the case of all file and directory names in the code and codebase elements solved the problem.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Thank you for answering, but this question was answered and accepted a looong time ago... You should try answering recent questions instead – alestanis Oct 20 '12 at 13:40
0

I was facing the same problem.The reason in my case was all dependency library that Applet uses was not signed and also applet not able to locate them.

So i Have added all the dependent library along with main applet in jsp file like below :

app.archive = '/esense/resources/lib/Applet.jar, /esense/resources/lib/jasypt-1.7.jar, /esense/resources/lib/mysql-connector-java-5.1.30.jar, /esense/resources/lib/runtime-api-1.0.jar';

I have also signed all the jar.

Hope this may work in your case.

naren_rana
  • 41
  • 2
0

I just clicked on maven->update project->include snapshot release in my spring boot and it worked.

Shubham Dixit
  • 9,242
  • 4
  • 27
  • 46