This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bad Magic number  RSS feed

 
Tony Realto
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I have very big problem.It's little server.Show only one class.
Problem.
When I write in IE 127.0.0.1/my.html (my.html have an applet (My.class)).Applet would be init but, I see General Exception.

java.lang.ClassFormatError: My (Bad magic number)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:148)
at sun.plugin.security.PluginClassLoader.findClass(PluginClassLoader.java:168)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:501)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1778)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
at sun.applet.AppletPanel.run(AppletPanel.java:293)
at java.lang.Thread.run(Thread.java:536)

When I tested this apllet on Apache this applet work.My server have a problem.But I what don't why?
Could you please give me some help?
When write ,writre whith simple words,I don't know very good english.
P.S. java version = 1.4.1_02

class Download extends Thread{
private Socket sock=null;

String request;
Download(Socket s) {
sock = s;
}

public void run(){
try{
BufferedReader b = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String req = b.readLine();
if (req.substring(0,5).equals("GET /")){

request=req.substring(5,req.length()-9);
BufferedInputStream in=new BufferedInputStream (new FileInputStream ("my/"+request));

PrintWriter o=new PrintWriter (sock.getOutputStream(),true);
request=request.substring(request.length()-6,request.length());
String res="text/html";
//MIME Type
// application/vnd.exe if exe
if (request.equalsIgnoreCase(".class")){
res="application/x-java-vm";
}

o.println("HTTP/1.1 200 OK");
o.println("Content-Type:"+res+"\n");

BufferedOutputStream out=new BufferedOutputStream(sock.getOutputStream());
int ch=in.read();
while(ch!=-1){
out.write(ch);
ch=in.read();
}
out.flush();
out.close();
in.close();
sock.close();
}
else{
b.close();
sock.close();

}
}

catch(FileNotFoundException e){

}
catch(Exception e){

}
}
}
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, welcome aboard!

Double check that the class file you have deployed is good. The error comes because the class loader didn't like the file. A google for "bad magic number" found this thread about the exception.
[ May 19, 2005: Message edited by: Stan James ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!