Results 1 to 4 of 4

Thread: Compiling problem???

  1. #1

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228

    Compiling problem???

    When I compile any Java program wit 'javac' its splits the main class file into different parts ( ex. MyClass.class, MyClass$1.class, and so on ) Then when I load them on the web ( they are for an applet ) the webshell makes the '$' a '_' because '$'s aren't aloud!! My javac didn't used to do that. Why is it? Any ideas????
    To protect time is to protect everything...

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Not sure about the web part but the $'s are produced by the compiler to mark the classes or interfaces within the inheritance heirachy. For instance the following code should produce the following class files when compiled.

    TopLevelClass$NestedTopLevelClass$NestedTopLevelClass1.class
    TopLevelClass$NestedTopLevelInterface1.class
    TopLevelClass$NestedTopLevelClass.class
    TopLevelClass.class

    Code:
     public class TopLevelClass {
       static NestedTopLevelClass{
      
       interface NestedTopLevelInterface1{
       } 
     
      static class NestedTopLevelClass1
       implements NestedTopLevelInterface1{
         }
       }
     }

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    SomeClass$1.class is for the first anonymous nested class you declare, $2 for the second etc.
    So
    Code:
    class MyClass
    {
      JButton button = new JButton();
      public MyClass() {
        button.addActionListener(new ActionListener() {
          public void actionPeformed(ActionEvent e) {
          }
        } );
      }
    }
    results in
    MyClass.class
    MyClass$1.class
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Addicted Member Virtual24's Avatar
    Join Date
    May 2001
    Posts
    228
    ahhh i see... cuz i was using:

    Code:
    addWindowListener( new WindowAdapter()
    {
        public void windowClosing( WindowEvent e )
        {
            //...
        }
    } );
    To protect time is to protect everything...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width