wood burning stoves 2.0*
The moose likes Applets and the fly likes Problem with an applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Problem with an applet" Watch "Problem with an applet" New topic

Problem with an applet

Vivek Alampally
Ranch Hand

Joined: Jul 10, 2008
Posts: 67
Hi everybody,
I have developed an applet using eclipse ide. When I tried to run it from ide(Run as Applet..) it works fine. The problem is when I tried to the same thing from an HTML file it is giving an exception

load: class Main.class not found.
java.lang.ClassNotFoundException: Main.class
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:\Documents\Main\class.class (The system cannot find the path specified)
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
Exception: java.lang.ClassNotFoundException: Main.class

What I did exactly is

1. I made a jar file of my project using eclipse ide. Using Export.....
2. Next I created an HTML file

<TITLE>applet experiment</TITLE>
<h1> first applet</h1>
codebase=C:\Documents and Settings\Vivek\Desktop\applet experiments

Where Main.java is a file which extends JApplet.
third.jar is a jar file which I created.
and C:\Documents and Settings\Vivek\Desktop\applet experiments is a directory in which third.jar file, my HTML file resides.

I will be very thankful if anyone can help me to solve this.

Lester Burnham

Joined: Oct 14, 2008
Posts: 1337
Are both the HTML file and Main.class in the C:\Documents directory? If so, try "code=Main" instead of "code=Main.class".
wood burning stoves
subject: Problem with an applet
Similar Threads
Applet throwing exception when running it through web browser
cannot open applet in firefox
Setting applet path in Java Servlet
My applet is not being seen in its jar anymore. Please help!
Loading java applet from a cab file failed