Java.lang.NoClassDefFoundError when trying to insert an applet

So, I wrote my code for the Snake game for a little kid that I know, and the damn thing will not be embedded in html.

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

and I'm sure the class file is in the same directory as snake.html , but it still refuses to run. He always answers:

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

Does anyone know why? Thanks.

EDIT:

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

0
java applet
source share
1 answer

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

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

Usually you specify "package.class" in the "code" attribute, i.e. com.stackoverflow.MyClass.class

+1
source share

All Articles