Possible Duplicate:
Compiler is creating extra class files with $ in them
I am using Netbeans to design a java app in which I am using Java Swing so apart from Java source files, I will have .form files which contains the description about the Java form.
In src diectory, I have 3 files like,
Downloader.java
DownloadCore.java
Downloader.form
Now, If I compile them manually using command prompt, (.i.e. without using Netbeans) then I am getting lot of .class files like,
DownloadCore.class
Downloader$1.class
Downloader$10.class
Downloader$11.class
Downloader$12$1.class
Downloader$12.class
Downloader$2.class
Downloader$3.class
Downloader$4.class
Downloader$5.class
Downloader$6.class
Downloader$7.class
Downloader$8.class
Downloader$9.class
Downloader.class
I am wondering why JVM creating this much of .class files, in which I have only 2 .java files, so it doesn’t supposed to create 2 .class files alone. Why is it required?
Thanks in advance
Every class has its own
.classfiles — even anonymous ones. For instance:This code snippet defines two classes —
MyWhateverand the anonymous class foranonymousRunnable. That second one will be calledMyWhatever$1, which is what you’re seeing. Each one of them will have its own.classfile.(By the way, it’s not the JVM creating these class files — it’s the Java compiler, like javac or whatever Netbeans uses. The JVM then loads these class files and executes them.)