1

I am having difficulties running my program from the appletviewer or from the html file i have created. I can run my compiled .class file just fine and eclipse generates my image, but i can't recreate this outside eclipse. All of my files are in the same directory as well.

AdvertisementApplet.html:

<html>
<head>
<title>AdvertisementApplet</title>
</head>
<body>
<center>
<applet code=”AdvertisementApplet.class” width="400" height="300"></applet>
</center>
</body>
</html>

AdvertisementApplet.java:

import javax.swing.JApplet;
import java.awt.*;
public class AdvertisementApplet extends JApplet{
public void paint (Graphics page){
page.setColor(Color.cyan);
page.drawRect (50, 50, 40, 40);
page.drawRect (80, 60, 40, 40);
page.drawOval (50, 50, 40, 40);
page.drawLine (50, 50, 40, 40);
page.drawString("out of clutter, find simplicity.", 110, 70);
page.drawString("—Albert Einstein", 130, 100);
    }
}

error message:

load: class ”AdvertisementApplet.class” not found.
java.lang.ClassNotFoundException: ”AdvertisementApplet.class”
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.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)
Exception: java.lang.ClassNotFoundException: ”AdvertisementApplet.class” 
Roman C
  • 49,761
  • 33
  • 66
  • 176
Nadia Wood
  • 13
  • 1
  • 3
  • Is the `.class` file in the same directory as `AdvertisementApplet.html`? – Eli Acherkan Sep 05 '12 at 09:10
  • yes along with my .java file. i read that some people got this to work by adding an archive option in the applet tag in the html file that had a path to a jar file with all of their class files in it, but that didn't work either.. http://www.coderanch.com/t/299494/JDBC/databases/running-applet-appletviewer-uses-JDBC – Nadia Wood Sep 05 '12 at 09:22
  • Why does the HTML and output have 'smart quotes'? Make sure the HTML has standard double quote characters and try it again. Report back. *"path to a jar file"* Is the class in a Jar file? If so, the applet element will need an `archive` attribute, if not, it is redundant & potentially problematic. – Andrew Thompson Sep 05 '12 at 10:31
  • removed and replaced smart quotes, no dice. others said this might be a classpath issue? – Nadia Wood Sep 05 '12 at 11:14

0 Answers0