kayahr
kayahr

Reputation: 22020

How to load a Java applet class from a subfolder with the embed tag?

I have a Java Applet as a single class file (No JAR file) in some sub directory and I want to embed it on a HTML page which is in a different directory. And I want to use the embed tag for it. But I can't get it working. This is my code so far:

<embed type="application/x-java-applet;version=1.6"
       width="512" height="512"
       code="subfolder/MyApplet.class" />

According to the Apache log file the Class file is loaded but it can't be started. Java says there is no class with name subfolder.MyApplet. So it treats the sub directory as a package name. A codebase parameter (No idea if this is valid for embed) doesn't make a difference. Maybe there is some other badly documented parameter to specifiy a code base directory from which to load the classes?

Please note that my question is not about how to embed a Java applet in general. I know how to get it running with the deprecated applet tag or the object tag and by packaging the class into a JAR file. My question is how to get it working in exactly this specific situation:

Upvotes: 1

Views: 5171

Answers (2)

lrivera
lrivera

Reputation: 524

Consider using the 'codebase' tag when using the 'embed' tag. For example,

   <embed type="application/x-java-applet;version=1.6"
       width="512" height="512"
       code="MyApplet.class" 
       codebase="subfolder/"/>

You should be able to use relative and absolute paths in the 'codebase' tag.

Hope that helps...

Upvotes: 4

Santosh
Santosh

Reputation: 17903

Try following:

<embed type="application/x-java-applet;version=1.6"
       width="512" height="512"
       codebase="subfolder/"
       code="MyApplet.class" />

Refer to this documentation.

Upvotes: 1

Related Questions