简体   繁体   中英

NoClassDefFoundError: Error in running applet in appletviewer

I just ran into trouble in applet execution in webpage: An error dialog popped up: 在此处输入图片说明

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?

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 yx .

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, ie 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, eg by finding the problem faster.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM