1

After successfully creating some applets, I embedded them in a webpage and discovered that ALL the class files must be included. Leave one out and it won't work.

After several iterations of an Applet, there are several class files:
filename.class
filename$1.class
filename$2.class, etc.

I tried using only the filename.class, tried just the last one, tried the first and last... but, as I said, all the class files must be included for the webpage.

Question(s):
1) The filename$n.class (n=some number) files seem to be created at the whim of Eclipse - is there an explanation of this (I searched w/o success)?

2) Even though the class files are only ~4kb, How do I do a cleanup such as to blow away all the filename$n.class files and still be able to embed in a webpage?

Any recommendations?

Thanks

headscratch
  • 531
  • 3
  • 15
  • 29

1 Answers1

8

These classes are created from anonymous classes created in your applet - most likely event listeners and such.

They would be created (maybe with other names) by other compilers, too.

If you really want to avoid them, program without anonymous (and other inner) classes. But this results often in an ugly style, so this is not recommended.

If you don't want to upload all the individual class files to the server (and then the browsers having to fetch them all individually), think about putting them all in one jar file, and referencing this in your applet-tag.

Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210
  • Thanks - that sort of makes sense as the number increased after adding a couple of listeners. Thus, I accept you answer but welcome other input as well... Thanks again! However (and I suppose I could test this out) if I delete a listener, can I delete the $n.class? Good Idea re the jar file (though, putting them in the webpage resource folder before uploading takes care of it - thus, no need to specifically do the uploads). – headscratch Feb 22 '11 at 01:26
  • You can delete all the `.class` files and recompile, this is a better way to be sure you didn't delete the wrong one. I suppose Eclipse is configurable to do this automatically, too (I'm not using it). – Paŭlo Ebermann Feb 22 '11 at 01:29
  • The odd thing about eclipse (as opposed to Netbeans, which I used for years) is there is no specific Compile (that I see) - you just Run (that does the compile but, there may be some settings I can change...) – headscratch Feb 22 '11 at 01:32