Incompatible magic value 1008813135
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.
Incompatible magic value 1008813135 in class file
1008813135 is <!DO in ASCII.
Probably the file "main.java" does not exist on the server and Java is trying to load the error page it got (starting with <!DOCTYPE) instead.
The archive attribute should most likely be the name of a jar file you uploaded to the server - not a class file and definitely not a java file.
Java Incompatible magic value 4022320623
Okay i figured it out with thanks to @Asaph mentioning the downloading going wrong..
Basically the downloading was fine, it was the way i was writing the file.
When im downloading projects, im downloading the source and binaries, but i was writing both files as if they were the same.
So changed the code to check the file type and then use the appropriate writer when necessary. If by some miracle someone has the same issue or is doing something similar here is the code:
(Note this was just written 5 second ago to fix the problem and is very poorly written, im about to refactor it myself, but i cant do everything for you)
public void download(String project, String version, String location)
{
for(S3ObjectSummary s: getObjectList())
{
String[] data = s.getKey().split("/");
if(data[0].equals(project) && data[1].equals(version))
{
S3Object object = s3.getObject(s3BucketName,s.getKey());
InputStream input = object.getObjectContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
File file = new File(location +"/"+ data[0] + "/" + data[2] + "/" + data[3] + "/" + data[4]);
if(!file.exists())
{
try {
file.getParentFile().mkdirs();
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
try
{
if(data[4].endsWith(".java"))
{
Writer writer = new OutputStreamWriter(new FileOutputStream(file));
while (true) {
String line = reader.readLine();
if (line == null)
break;
writer.write(line + "\n");
}
writer.close();
}
else if(data[4].endsWith(".class"))
{
System.out.println("Writing Classes");
byte[] buffer = new byte[8 * 1024];
try {
OutputStream output = new FileOutputStream(file.getAbsolutePath());
try {
int bytesRead;
while ((bytesRead = input.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
} finally {
output.close();
}
} finally {
input.close();
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
java applet fail when launched with server incompatible magic value 1013478509
According to the Java Language Specification, a proper .class
file has starts with the magic number :
The magic item supplies the magic number identifying the class file
format; it has the value 0xCAFEBABE.
If you open any compiled .class
file with a hex editor and inspect its first bytes, they should be 0xCAFEBABE
. 1013478509
in ASCII translates to <htm
.
Make sure you've got the class properly compiled on the server. And more likely, as BalusC already pointed out in his answer, make sure URL's are correct. The <htm
... bytes you're getting might be an HTML error document served by the server.
java.lang.ClassFormatError: Incompatible magic value 218774561
The original problem seems fixed now. I could download the Jar from http://dementedgames.site88.net/Evolution.jar
Update
It seems the Evolution.Evolution
class is not an applet! Running it from the command line using:
java -jar Evolution.jar
Produces a frame (with a very 'retro' look)! As such, forget this applet nonsense, and launch the frame from a link using Java Web Start.
Old Answer
OTOH it now throws a ClassNotFoundException
that (after inspecting the Jar) makes me think it should be:
<html>
<head>
<title>Evolution</title>
</head>
<body bgcolor="#000000" text="#906060">
<center>
<applet code="Evolution.Evolution" archive="Evolution.jar" width="800" height="600">
</applet>
</center>
</body>
</html>
There are two changes to the code
attribute worth noting.
- The
.class
extension was removed. A minor matter, adding it is tolerated, but not correct. - The
Applet
removed from the class name.
Related Topics
How to Remove Single Character from a String
Is a Java Array of Primitives Stored in Stack or Heap
How to Convert Ascii Code (0-255) to Its Corresponding Character
Increasing the Jvm Maximum Heap Size for Memory Intensive Applications
Is There a Fixed Sized Queue Which Removes Excessive Elements
Open a Link in Browser with Java Button
How to Schedule a Task to Run at Periodic Intervals
Return Generated PDF Using Spring MVC
File Upload with Java (With Progress Bar)
What Objects How to Inject Using the @Context Annotation
How to Extract a Tar File in Java
List.Clear() VS List = New Arraylist<Integer>();
How to Add an Image to a Jbutton
How to Change a Field Name in JSON Using Jackson