• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems with applet running in IE brwser

 
Paul Wagner
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I have written an applet, the code is the following

import java.awt.Graphics;
import java.applet.*;
public class HelloWorld extends Applet{
public void paint(Graphics g){

g.drawString("Hello World", 15, 30);
}
}

This runs fine in Eclipse.. But when I want to embedd this applet in html. Following is the html code

<html>
<body>
<applet code=HelloWorld height=100 width=100/>
</body>
</html>


The IE browser just shows an error message

java.lang.NoClassDefFoundError: HelloWorld (wrong name: helloWorldApplet/HelloWorld)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

WHERE IS THE PROBLEM ? ClassPath is set, Path is set. In Eclipse its running, but not in IE.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Programmer newbee , please check your private messages.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your code have a "package helloWorldApplet" statement that you didn't post? If so, then the applet tag should read like "code=helloWorldApplet.HelloWorld".
 
Paul Wagner
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnx dittmer,

but when I add that, i get these exceptions


Laden: Klasse helloWorldApplet.HelloWorld nicht gefunden
java.lang.ClassNotFoundException: helloWorldApplet.HelloWorld
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\Users\....\helloWorldApplet\HelloWorld.class (Das System kann den angegebenen Pfad nicht finden)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Ausnahme: java.lang.ClassNotFoundException: helloWorldApplet.HelloWorld
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the HelloWorld.class file inside of a folder called "helloWorldApplet" which itself is in the same folder as the HTML file? That's how the files must be organized.
 
Paul Wagner
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops you are right... I had put class file and html file in the same folder... it should be other way... class file in its own folder and html file and class folder should be in the same folder...
.
some time small things take more time to solve
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic