Вопрос

I made a java applet in eclipse and I am trying to embed it in a webpage. I exported the jar file, and my html looks like:

<html>
    <head>
        <title> Title </title>
    </head>
    <body>
        <applet code ="Game.class" archive="applet.jar" width = "854" height="641">

    </body>
</html>

I am getting a class not found exception for Game.class. I used 7 zip to check that Game.class exists and it does. Can anyone help?

Это было полезно?

Решение

I declare my package at the top of Game: package edu.elon.game;

Then you need to specify this in the applet tag code tag to match the fully qualified class name

<applet code ="edu.elon.game.Game.class" archive="applet.jar" width = "854" height="641">
               ^-----------^
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top