tags:

views:

17

answers:

1

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>

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.

EDIT:

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

A: 

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

Generally you specify 'package.class' in the 'code' attribute, i.e. com.stackoverflow.MyClass.class

ZloiAdun
Thank you that was exactly what I needed.
piggles