Take the 2-minute tour ×

So I have created an applet in Java, and would like to export it as a jar, then attach it to a webpage.

alt = "Dynamic Tree Applet Demo"
code = 'image.Main'
archive = 'Main.jar',
width = 300,
height = 300 />

This is basically my html code. The jar was exported from ecplise. Everything is in a package image. There is a public static void main, in the java file that runs the applet, not sure if that is even needed.

However, when I create either a regular or a runnable jar, I get lots of errors..

With a regular jar, and thus no main set in the manifest:

load: class image.Main not found.
java.lang.ClassNotFoundException: image.Main
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)
Caused by: java.io.FileNotFoundException: C:\Users\Daniel\Desktop\ImageCapture\New folder\image\Main.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)
... 9 more

Exception: java.lang.ClassNotFoundException: image.Main

I get the same error when using a runnable jar, exported from eclipse, which doesn't run, by the way. The jar does absolutely nothing when double clicked, not even the main-class missing error.

The manifest has the proper main-class setup when using the runnable jar, image.Main.

The classpath in that instance is just : .

Thanks in advance, hope my information was detailed enough.

share|improve this question
add comment

2 Answers

Applet should use public void init() as entry point, and not the public static void main. Export as jar file should be enough, don't export as runnable jar.

share|improve this answer
In this instance, I got it working with a runnable Jar, simply because that was the only way that I could get eclipse to package my other used jars. However, I removed the public static void main, as it serves no purpose. –  user633314 Feb 25 '11 at 13:02
add comment

1) The way you defined the applet tag, your Main.jar has to be in the same folder as the html page. Make sure it is.

2) Make sure your exported jar contains the class file(s). You can use any zip explorer (WinZip, WinRAR, etc) to open the jar file and make sure there's a folder named image with a file named Main.class in it. You can also use the command

jar -tf Main.jar

to list the contents of the jar file.

3) Class and package names are case sensitive in Java, so make sure you have the correct case for both.

share|improve this answer
I got it working, thanks. –  user633314 Feb 25 '11 at 13:05
add comment

Your Answer


