Vasu
Vasu

Reputation: 1110

HTML Java applet integration

I know this has been asked multiple times already, and I have already tried to use all of the solutions that I could find, but I wasn't able to get any success. I have a JApplet that works successfully (I've pasted the heirarchy below, as I don't think the code itself is relevant to the issue. I might be wrong). I also have some basic HTML code that seems to be correct based on the solutions that I have found. The problem is that I continue to get the same error:

error
(source: gyazo.com)

And I'm not sure why I'm getting it. Is it because everything in the heirarchy is a .java file?

my HTML file:

<html>
    <head></head>
        <body>
            <applet width="950" height="600" archive="test.jar" code="OneQuestMapgen.OneQuestMapgen.class"></applet>
        </body>
</html>

Hierarchy:

hierarchy

Files:

files

Any help would be appreciated. Thanks so much!

Upvotes: 0

Views: 357

Answers (4)

joaonlima
joaonlima

Reputation: 618

First, you need to close you <head> tag with </head> and do the same with the <body> tag.

Also, the <applet> tag has been deprecated in HTML4.01 and is not allowed in HTML5, so you should replace for <object> tag

So, if you are using it on Chrome, for instance. It will NOT work.

Upvotes: 1

fGo
fGo

Reputation: 1146

Shouldn't your html be like this?

<html>
<head></head> <!-- closing the head before the body -->
<body>
  <applet width="950" height="600" code="OneQuestMapgen.OneQuestMapgen.class" 
    type="application/x-java-applet;jpi-version=6" 
    archive="test.jar">
</body>
</html>

in html5 it should be something like

<object type="application/x-java-applet" height="600" width="950">
  <param name="code" value="OneQuestMapgen.OneQuestMapgen.class" />
  <param name="archive" value="test.jar" />
  Applet failed to run.  No Java plug-in was found.
</object>

Upvotes: 0

Lucian Enache
Lucian Enache

Reputation: 2520

If your applet is in the same dir. as the html file you don't need to specify it as the browser searches for a location of the document in the same dir, if you have it elsewhere then it's ok to have the archive which should containt the path to the jar file.

Beside that you should consider adding to the code attribute also the package in which your class resideds, all separated by a dot code="OneQuestMapgen.OneQuestMapgen.class"

Upvotes: 0

Ketan Bhavsar
Ketan Bhavsar

Reputation: 5396

Can you try..

<applet width="950" height="600" archive="test.jar" code="OneQuestMapgen.OneQuestMapgen.class">

Upvotes: 1

Related Questions