Hi all, i'm pretty new to java applets and been struggling to embed it into a webpage. I made a java applet using eclipse, and ran it using eclipse's applet viewer just fine. However i cannot embed it into my webpage.

I placed the jar file i exported from the project into the same location with this html file, and in the html file, i put the following code

<html>
<applet code="RectanglesMover.class" archive="BinPacking.jar" width="500" height="500">
<p>
Sorry, you need a Java-enabled browser to run this applet.
</p>
</applet>
</html>

I checked the names correctly entered but keep getting the Class not found message. I checked the jar file too and saw the applet file there already.

t keep getting the Class not found message

Please copy and paste the full text of the error message here.

Your problem could be that the browser is looking for the class:
class in the RectanglesMover package
contained in the file: RectanglesMover.class.class

If so, remove the .class from the code= attribute

you dont use the jar file. Just copy the class files into your storage area for your website and then navigate to it. Like so

<html>
  <head>
    <title>
       The ArrowKeys2menuprob2 applet
    </title>
  </head>
  <body>
    <h2>
      Here is the YourAppletName applet
    </h2>
    <hr>
    <applet code="RectanglesMover.class" width="500" height="500">
    </applet>
    <hr>
  </body>
</html>

you want to navigate to the directory (if you have any) in front of the RectanglesMover.class

Edited 5 Years Ago by sirlink99: n/a

@NormR1: here is the error message

load: class RectanglesMover.class not found.
java.lang.ClassNotFoundException: RectanglesMover.class
	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)
Exception: java.lang.ClassNotFoundException: RectanglesMover.class

@sirlink99: i need it to be in a jar file because i need to call a custom class in my package.

If so, remove the .class from the code= attribute

I tried that approach but it's still the same error. :(

it's still the same error

Are you sure, the text of the message should change from

ClassNotFoundException: RectanglesMover.class

to

ClassNotFoundException: RectanglesMover

I gave you two choices for the text of the error message.
Which one is the one you are getting? The first one or the second one.

What class files are in the folder with the html file?

Edited 5 Years Ago by NormR1: n/a

i get the

"load: class RectanglesMover.class not found." error

And even tho' i removed the ".class" or not it's still the same error. And yes the jar file and the html file are in the same folder

class RectanglesMover.class not found.

The browser is looking for a class named: RectanglesMover.class
It looks for that class in a file named: class.class in the RectanglesMover folder.
Does the jar file have that file in that folder?

What is the text of the message when the .class is removed?

Still the same error, as i told you above:

"load: class RectanglesMover.class not found."

i looked into the jar file and yes that file is there in the jar file, and i did not type the name incorrectly.

"load: class RectanglesMover.class not found."

What browser are you using?
Without the .class on the code= I expect you to get this error message:
"load: class RectanglesMover not found."

Notice there is no .class after RectanglesMover

This article has been dead for over six months. Start a new discussion instead.