ClassNotFoundExeption嵌入的网页小程序时 [英] ClassNotFoundExeption when embedding applet in webpage

查看:204
本文介绍了ClassNotFoundExeption嵌入的网页小程序时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了Eclipse的一个Java小程序,我试图把它嵌入在网页中。我出口的jar文件,我的HTML如下:

 < HTML和GT;
    < HEAD>
        <标题>标题< /标题>
    < /头>
    <身体GT;
        <小程序code =Game.class档案=applet.jarWIDTH =854HEIGHT =641>    < /身体GT;
< / HTML>

我收到了Game.class一类未发现异常。
我用7拉链检查Game.class存在,并且它。谁能帮助?


解决方案

  

我宣布我的包在游戏的顶部:包edu.elon.game;


然后,你需要在applet标记来指定这个 code 标签相匹配的完全限定类名

 <小程序code =edu.elon.game.Game.class档案=applet.jarWIDTH =854HEIGHT =641>
               ^ ^ -----------

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">
               ^-----------^

这篇关于ClassNotFoundExeption嵌入的网页小程序时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆