0

I have tried everything. I am using 000webhost to test the applet. So I uploaded the java file

package game;
import java.applet.*;
import java.awt.*;

public class main extends Applet implements Runnable
{
int x_pos = 10;
int y_pos = 100;
int rad = 20;

public void init()
{
    setBackground (Color.blue);
}
public void start()
{
    Thread th = new Thread (this);
    th.start();
}
public void stop()
{

}
public void destroy()
{

}
public void run()
{
    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

    while(true)
    {
        x_pos ++;
        repaint();
        try
        {
            Thread.sleep(20);
        }
        catch(InterruptedException ex)
        {

        }
        Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
    }
}
public void paint(Graphics g)
{
    g.setColor(Color.red);
    g.fillOval(x_pos - rad, y_pos - rad, 2*rad,2*rad);
}

}

to the server. I checked the hex code and the first 4 bit digits were CAFEBABE. Then the Html was <head> <h1 align = "center">Test</h1> </head> <body> <applet code = "game.main" archive = "main.java" width = "40" height = "40"> </applet> </body> </html>

Any ideas why I get the Incompatible magic value 1008813135 in class file error?

dr0id
  • 3
  • 1
  • 3

1 Answers1

1

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.

user253751
  • 57,427
  • 7
  • 48
  • 90