jsh6303
jsh6303

Reputation: 2040

NoClassDefFoundError: Error in running applet in appletviewer

I just ran into trouble in applet execution in webpage: An error dialog popped up: enter image description here

The calculator is my class name and Exercise4 is the folder that contains it. I am sure that the html file and the calculator.class are in the same folder named Exercise4. What is happening in here?

Upvotes: 0

Views: 298

Answers (1)

Holger
Holger

Reputation: 298263

You are mixing up directories and packages. If you class has the name x and resides in the package y your codebase must not point to the directory y. Instead the codebase must point to the parent directory of y and the class name must be specified as y.x.

So in your case you seem to have specified a directory Exercise4 which ought to be the package name and an applet class of calculator which is wrong as it ignores the package name.

As said you have to specify the parent directory of the package directory structure, i.e. the parent directory of Exercise4, as the codebase and specify Exercise4.calculator as the applet class.

Note that package names should be lowercase and class names be uppercase by convention. Adhering to conventions helps other people help you on problems, e.g. by finding the problem faster.

Upvotes: 1

Related Questions