NoClassDefFoundError的时候试图嵌入一个app

NoClassDefFoundError的时候试图嵌入一个app

本文介绍了java.lang.NoClassDefFoundError的时候试图嵌入一个applet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我写了我的code的贪吃蛇游戏,因为我知道一个孩子和该死的东西不会嵌入本身的HTML。

So I wrote my code for a Snake game for a kid I know and the darned thing won't embed itself in html.

<html>
<head>
<title>Snake</title>
</head>
<body>
<applet width=200 height=100 code="SnakeGame.class">
</applet>
</body>
</html>

和我敢肯定,这个类文件在同一目录 snake.html ,但它仍然拒绝执行。它总是回复:

and I am certain that the class file is in the same directory as snake.html, but it still refuses to run. It always replies:

java.lang.NoClassDefFoundError: SnakeGame (wrong name: view/SnakeGame)

有谁知道为什么吗?谢谢你。

Does anyone know why? Thanks.

编辑:

文件夹视图载: SnakeGame.class ,和所有其他类游戏,以及在HTML

the folder view contains: SnakeGame.class, and all the other classes for the game, as well as the html

推荐答案

看来,在视图 SnakeGame 包,让你的小程序标记应该是这样的:

It seems that SnakeGame class in in the view package, so your applet tag should look like:

<applet width=200 height=100 code="view.SnakeGame.class">

通常你在code'属性指定'package.class,即 com.stackoverflow.MyClass.class

这篇关于java.lang.NoClassDefFoundError的时候试图嵌入一个applet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 11:45