• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with an applet  RSS feed

Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are both the HTML file and Main.class in the C:\Documents directory? If so, try "code=Main" instead of "code=Main.class".
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!