File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Packaging Classes Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Packaging Classes Question" Watch "Packaging Classes Question" New topic
Author

Packaging Classes Question

Cyrus Serrano
Ranch Hand

Joined: Sep 29, 2003
Posts: 137
Hello all,



just wondering, when i tried to compile a class that has a package statement, it generates 2 class files. For example my source file name is : Form.java, after compilation it will generate:



Form1.class and Form$1.class



Why is there an extra class file with a dollar sign....
Martyn Clark
Ranch Hand

Joined: Apr 16, 2005
Posts: 108
Hi it's not because you have the the file in a package. You get two files when you have created a source file with an inner class, When you create a class with an inner class, two files will be created when you compile the source file the inner class being the one with the dollar sign.


Martyn...<br /> <br />SCJP 1.4 SCWCD 1.4
Cyrus Serrano
Ranch Hand

Joined: Sep 29, 2003
Posts: 137
thank you for the reply, but there are no inner classes in my program, here is a code snippet of one of my class files:

package com.StiCalJava.event;

import java.awt.*;
import java.awt.event.*;

public class Form2 extends Frame
{
public Form2(String str)
{
super(str);
setSize(300,300);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);

setVisible(true);
}
}



it thus, generate 2 class files Form2.class and Form2$1.class
Is there an inner class in my program.. thanks
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Your code contains an anonymous inner class, which is derived from WindowAdapter.

Note that the class file is $1 because the inner class is anonymous. If you had a named inner class it would be $NameOfInnerClass.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Packaging Classes Question