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
It seems that
SnakeGameclass in in theviewpackage, so your applet tag should look like:Generally you specify ‘package.class’ in the ‘code’ attribute, i.e.
com.stackoverflow.MyClass.class