ClassNotFoundException Java Applet

Sticky picture Sticky · Aug 3, 2014 · Viewed 13.3k times · Source

I get the ClassNotFoundException error when I make my html file with the code and jar file. Not sure why. Here's what I have:

 <html>
<head>
<title>
Test Applet
</title>
</head>
<body>
<h2>Test Applet</h2>
<applet
code="Testing.class"
archive="myTestJar.jar" 
width=550 height=300>
</applet>
</body>
</html>

I simply have the class in a jar file and tried to reference using archive but it doesn't work.

Answer

Deepanshu J bedi picture Deepanshu J bedi · Aug 3, 2014

try this

<applet code=Testing.class
        archive="myTestJar.jar"
        width=550 height=300>
</applet>

The class has your main() I assume, the jar is the entire thing.

if,you're not taking packages into consideration. For instance, if the package is myPackage.vol3 then the line should read

<applet code="myPackage.vol3.Testing.class" archive="myTestJar.jar"

and put the html file in the project folded "INSIDE" the project folder.