4

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.

Sticky
  • 3,671
  • 5
  • 34
  • 58

1 Answers1

1

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.

Deepanshu J bedi
  • 1,530
  • 1
  • 11
  • 23
  • Thanks! I am having trouble doing the package thing however. My main class is in the default package, is that the right place? I have tried to reference a .class file outside a jar file and Firefox reads it but when placed in a jar file, Firefox says .class file is not found. That is the reason I am baffled. – Sticky Aug 20 '14 at 00:46
  • When you place it in the jar file you have to use archive="myTestJar.jar" – Deepanshu J bedi Aug 20 '14 at 20:59