views:

265

answers:

2

Hi all,

I am building a small applet in java. It works fine (really!) when I run it in eclipse as an applet. Problems start when I export it as a jar and than try to load it through an html page. Here's the html code:

<body>

<applet  archive="myJar.jar" width=650 height=850>

</applet>
</body>

Now when I run other jar files in this way they work fine, for example if you view the source page of this niffty demo

    <body>
    <applet code="org.niffty.Niffty.class" archive="niffty.jar" width=650 height=850>
    <param name="file" value="prelude.nif">
    </applet>
    </body>

Thank you!

+3  A: 

You're missing the code attribute in your applet tag. Without it, the browser doesn't know which class in your JAR file is the applet it should display.

Michael Borgwardt
I see, well thank you very much
vondip
+2  A: 

You've specified the archive, but no code attribute so the applet runner doesn't know which class to use as the entry point. You have to either specify code or specify the object attribute to give a serialized applet instance - but code is much more likely to be appropriate for you.

See the documentation for the applet tag for more information.

Jon Skeet