MyClass$1.class files when I compile

When I compile as follows
javac myclass.java
the following files get created
myclass$1.class
myclass$2.class
myclass.class
why am i getting the first two .class files?
i'm running jdk 1.3.1 and i also have Forte CE 3.0 installed.
this never used to happen.
does it have something to do with Forte??
Any help please

Your source code includes an annonymous inner class - something like
new WindowAdapter() {
The compiler generates this .class file for this 'class' with no name. Search the forum for "$1.class" for more/better explanation. Here's one thread.
http://forum.java.sun.com/thread.jsp?forum=7&thread=13504

Similar Messages

  • Two class files with $ on compile

    Hello friends, I have a simple java program, that consists of two classes, coded in the the same java file.
    One of hte classes extends Thread.
    When I compile the source file, I get one class file for the base class, and two for the other one - ClassName.class and ClassName$1.class.
    Why is the second one created?

    The ClassName$1.class is a class file for an anonymous inner class. You create them with code likebutton.addActionListener(new ActionListener() {
         actionPerformed(ActionEvent ae) {
              System.out.println("button was pressed");
    });This particular example is from the GUI world where event listeners are commonly created using anonymous inner classes. There's a separate file for it just because there's always exactly one class file for each class.

  • Getting generated class files using the compiler api??

    I am writing a compiler/IDE for java, and i use the new JavaCompiler API
    (javax.tools.JavaCompiler)
    i want to ask, is it possible to get the generated class file(compiled file) names??
    can anyone help me with this, read at the documentation and i have no idea which one is used to do such thing..
    Or is it impossible??
    Thanks, please guide me on this..

    E.D.-inc wrote:
    I am writing a compiler/IDE for java, and i use the new JavaCompiler API
    don't.
    i want to ask, is it possible to get the generated class file(compiled file) names??
    yes, probably (after all, other tools can do it). Don't ask me how though, I've never had a need to.
    can anyone help me with this, read at the documentation and i have no idea which one is used to do such thing..
    no. Someone else reading the documentation for you won't help you any. Read it yourself, you might learn something.

  • How to decomplie a java class file when java application is running/launch?

    I have a simple java application with some components being displayed, now i need to get the components instance names that are been created in that java application. How do i do that?
    Eg: Button b1 = new button();
    now how to write a java application to decompile this class file & return me the button instance ie "b1".

    I think you wanna do two different things:
    1. find out which objects were created at runtime.
    2. decompile class file.
    I'm no so sure why.
    have you tried insrospecting the class using reflection ?
    Here is a code snippet that prints class field names.
    try{
      Class c = Class.forName("MyClass");
      java.lang.reflect.Field[]  f=    c.getFields();
      for (int i = 0;i<f.length; i++)
           System.out.println(f.getName());
    catch(Exception e){ }
    Regards
    Joseph.

  • Loading new class files when they are not available when the JVM starts

    Simple Question
    Is it possible to load class if it was not compiled when the original JVM was launched?
    More Detailed Question
    Our build system is getting a slight tweak with a new test runner. After our build system compiles the file, I would like to be able to load the files that have just been compiled.
    Our build system runs inside its own JVM and calls ant scripts to run the different processes(Separate JVM). The new test runner will also be called from the build system(Same JVM) but not as an ant target. Is it possible to call the newly compiled files from inside the build system JVM if they had not been created on the start of that JVM using reflection?
    Thanks in Advanced!

    public class t
        public static void main(String args[])
         throws Exception
         Writer out = new FileWriter("Foo.java");
         out.write("public class Foo implements Runnable {\n");
         out.write("    public void run() {\n");
         out.write("        System.out.println(\"run like the wind\");\n");
         out.write("    }\n");
         out.write("}\n");
         out.close();
         Runtime.getRuntime().exec("javac Foo.java").waitFor();
         ((Runnable) Class.forName("Foo").newInstance()).run();
    }

  • Avoid *$1.class files after the compilation

    Hi
    i made an applet called ChatClientApplet.java ... As a result from the Compilation, I receive the classes
    ChatClientApplet.class
    ChatClientApplet$1.class
    ChatClientApplet$2.class
    I'd like to avoid these $ files or to choose a different character... How can i do that?
    Thank's
    Fabio
    [email protected]

    Don't use inner classes. If you use inner classes you always get classes with a $ inside it.
    Use outer classes to avoid this naming.
    Uwe

  • Referenced XML,class files when trying to launch a extended page from JDev.

    Hi,
    I have identified the objects that I need in order to extend a R12 standard OAF page. I have also coded for the relevant extension. Now when i try to test it from JDEV itself, i get all these class not found errors for various referenced objects (eg in shared regions) from various subdirectories under $JAVA_TOP/oracle/apps on the application server. To overcome this i brought over the objects from $JAVA_TOP/oracle/apps into a local directory on my machine and in JDev i created a library giving that directory as the source path and then in my project added that library. BUT it is still giving the same errors....
    how do i overcome these errors ?
    thank you.

    Hi,
    What you are trying to do is correct, except few points,
    You mentioned +"$JAVA_TOP/oracle/apps into a local directory"+
    but can you put them in your myclasses oracle/apps directory.
    And what is the exact error you are getting.
    Btw, you can refer the below links about how to setup the Jdev to prepare for customizations,
    http://apps2fusion.com/apps/14-fwk/456-iexpenses-oa-framework-r12-extensions
    http://oracle.anilpassi.com/running-oa-framework-page-from-jdeveloper-audio-video-demo-2.html
    Thanks,
    With regards,
    Kali.
    OSSi.

  • Empty MyClass$1.class

    Hi,
    Let's say I have a class called MyClass, with an inner class MyInnerClass.
    When I compile with my IDE, I have two resulting class files:
    MyClass.class
    MyClass$MyInnerClass.class
    But when I compile using an Ant script, it generates the following class files:
    MyClass.class
    MyClass$1.class
    MyClass$MyInnerClass.class
    When decompiling the MyClass$1.class, it gives me this strange empty class:package mypackage;
    static class
    }How can I avoid those additional class files to be generated?
    Thanks.

    I'm using Eclipse IDE, and I run my Ant script from Eclipse too.
    However, I can't find any relevant option regarding project compilation (Although I can set JDK compliance, I can't even find which JDK is used by Eclipse and how to set it...)
    Anyway, I only have j2sdk1.4.2_04 installed. So I guess they both use the same one.
    BTW, I had some problems using Ant. It doesn't seem to use JAVA_HOME env var. I had to explicitly add Java's Tool.jar lib to Ant's classpath in order to make javac task to work.
    Is there any cleaner way?
    A concrete dummy example:public class MyClass {
         private MyInnerClass member;
         public MyClass(long id) {
              member = new MyInnerClass(id);
         public static class MyInnerClass {
              private long id;
              private MyInnerClass(long id) {
                   this.id = id;
              public long getId() {
                   return this.id;
    }When compiling it using IDE's build tool, it generates two class files.
    But when I run my Ant script, it generates 3 class files (i.e. this additional MyClass$1.class)
    Note that my decompiler generate same code from the two versions of MyClass$MyInnerClass.class
    For info, here is my simple Ant javac task:<target name="compile" depends="init,clean" description="Compile java classes">
         <javac srcdir="${src.dir}/java" destdir="${build.dir}/java">
              <classpath>
                   <fileset dir="${lib.dir}">
                        <include name="**/*.jar"/>
                        <include name="**/*.zip"/>
                   </fileset>
              </classpath>
         </javac>
    </target>Although I don't consider this issue as critical at all, any clue would be appreciated...
    I feel like a Bug spending my life trying to work with Ant...[i]

  • Compiling class file to WEB-INF/classes

    I have created 2 source files, viz: DatabaseConnectionBean.java and Agent.java. They both exist in the source directory. In the DatabaseConnectionBean.java I instantiate the Agent.class. When I compile at the Command prompt ... I type javac -d ..\WEB-INF\classes\ Agent.java ... it compiles fine. But when I compile the DatabaseConnectionBean.java by typing javac -d ..\WEB-INF\classes\ DatabaseConnectionBean.java it throws an error.....it cannot resolve symbol 'Agent'.
    I have included the package name, viz: smeyl, in both files.
    A strange thing happens when I type: javac -d ..\WEB-INF\classes\ *.java; at the command prompt...It doesn't throw an error....it compiles both source files....still though my jsp doesn't work properly..so this isn't a solution.
    Please help.
    any help will be appreciated....
    luv
    ushanta

    I'm not to sure myself. I've been using eclipse too long to remember all the intracacies of command line stuff. I know the theory, but am out of practice. :-)
    If you compile DatabaseConnectionBean on its own, I don't think it looks in the destination directory for supporting classes unless you tell it to:
    something like this
    javac -d ..\WEB-INF\classes\ -classpath ..\WEB-INF\classes\;%CLASSPATH% DatabaseConnectionBean.java
    If I'm talking complete rubbish here, someone will kindly (or unkindly for that matter) correct me I am sure

  • Java error message - Bad version number in .class file

    I get the  error noted below in Safari, Firefox, and Chrome when I try to view java containing web pages.
    Specifically this page: http://aviationweather.gov/adds/tafs/java/
    My Java Preferences are as follows
    My OS is 10.5.8
    Thanks!
    Java Plug-in 1.6.0_26
    Using JRE version 1.5.0_30-b03-389-9M3425 Java HotSpot(TM) Client VM
    User home directory = /Users/ernest
    c:   clear console window
    f:   finalize objects on finalization queue
    g:   garbage collect
    h:   display this help message
    l:   dump classloader list
    m:   print memory usage
    o:   trigger logging
    q:   hide console
    r:   reload policy configuration
    s:   dump system and deployment properties
    t:   dump thread list
    v:   dump thread stack
    x:   clear classloader cache
    0-5: set trace level to <n>
    java.lang.UnsupportedClassVersionError: Bad version number in .class file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)
        at java.lang.reflect.Method.invoke(Method.java:592)
        at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Plugin2ClassLoader.java :1014)
        at sun.plugin2.applet.Plugin2ClassLoader.access$100(Plugin2ClassLoader.java:69)
        at sun.plugin2.applet.Plugin2ClassLoader$2.run(Plugin2ClassLoader.java:991)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Plugin2ClassLoader.java:9 55)
        at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:134)
        at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:250)
        at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:180)
        at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:161)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Plugin2ClassLoader.java:675)
        at sun.plugin2.applet.Plugin2Manager.createApplet(Plugin2Manager.java:3046)
        at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.ja va:1498)
        at java.lang.Thread.run(Thread.java:655)
    Exception: java.lang.UnsupportedClassVersionError: Bad version number in .class file

    Hi, thank you for the reply.  However, java is definitely enabled on my computer, on all my browsers.  In fact, if I go to the SUN website and run the java test, I get that all is OK.
    I think it may have something to do with the .class (maybe in .jar-file) compiled with a higher version of java than the virtual machine trying to run it. 
    The example I found (google search) is .class-file that is compiled with JDK 6 and I am trying to run it with 1.4 JVM.
    There is some software error going on somewhere... but I do not know enough to fix it.
    Many thanks for all your help

  • MyClass$1.class and so on

    hi,
    i used SUN ONE STUDIO 4
    i created a JFrame Application with it.
    and now after long time i have these in the project directory
    of course
    MyClass.class
    MyClass$1.class
    MyClass$2.class
    MyClass$3.class
    MyClass$4.class
    MyClass$5.class
    MyClass$6.class
    MyClass$7.class
    MyClass$8.class
    anybody can tell me what are these?
    and how can i delete remove them?
    i even created a new MyClass.java and copied the code into the new java file.
    i compiled i got the same XXX.class files.
    thx

    The MyClass$x.class files are from inner classes... if you do something like this:
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent we) {
    frame.dispose();
    That's creating an inner class for the window adapter. One of the extra class files is containing this. If you delete them, and try to run from the main class file first, the JVM will complain about missing classes.

  • Problem with:error: java.lang.ClassFormatError: Truncated class file

    Hello, I created an simple applet writing "hello world". Now I would like to add *.class file to my serwer witch I've implemented on microcontroller P89C51RD2BN.
    Serwer is programmed with hex file which is created after compiling C source files. In this case I converted .class file to array in C (using hexedit program). When I am (using IE ) browsing my serwer Html site is loading corectly and *.class file is send from serwer also corectly (define arrays are transfered corectly) but applet is not initiated. When I am runnig Java console I can see this:
    error: java.lang.ClassFormatError: Truncated class file
    When I am runnig the same site with the same class file on my PC everything is ok.
    I would be greatfull for any help. Thx. (sorry for my English :P )

    Not too familiar with native compilation, which I believe you are trying to accomplish here. It would appear that you don't have any problems running your applet, more or less running it after being converted to legacy code. Try the "native methods" forum under "Fundementals/Key Classes", this may be helpful. Sorry for not being too helpful.

  • Same source always makes same .class file ?

    Compiling same source code will result always in same .class file ? (off course using the same compiler).
    I've seen a site that says the compiler puts a timestamp in the class file. So compiling again at a different time will not result in same .class file.

    _cristi_ wrote:
    I have tested, so far class files seem to be identical.
    But in a large project there might be cases when they differ, that's why I've asked, I can't be 100% sure based on a few tests.
    Certainly won't be based on timestamp then.
    I need this to extract only the class files that have been changed in order to deploy them.
    There is a jar compare tool out there that first decompiles the classes and then compares the resulted text. They say this is necesarry because of timestamp in class files. Link: http://www.extradata.com/products/jarc/
    I suggest you ask them to document the claim about the timestamp. They are selling a product and thus the bias can be questioned.
    And that sample diff they provide is absolutely pointless because 1.5 versus 1.4 is guaranteed to be different because of the class version difference.

  • Looking in the wrong directory for class file

    My javabean looks like this:
    <jsp:useBean id="mailer" class="MailerBean">
    <jsp:setProperty name="mailer" property="*"/>
    <% mailer.sendMail(); %>
    </jsp:useBean>
    The actual MailerBean.class file is in ROOT/public_html/servlets directory. The file that uses the above javabean is in ROOT/public_html/clearresults directory. I have tried a bunch of different lines of code to point to the servlets directory with no success. The javabean continues to point to the ROOT/public_html/clearresults/MailerBean.class file when it should point to ROOT/public_html/servelts/MailerBean.class. How can I point the MailerBean class to the servlets directory without moving the file that uses the javabean?

    Generally you don't have to write code to say where a class is, and I don't know what "pointing" a class is. Things that run servlets and JSPs have rules about where they will look for classes. All you have to do is put your MailerBean class where the rules say to put it. Often that's a directory called something like .../WEB-INF/classes, but check out the rules for your product.

  • Class file viewer

    is there any simple method to view the class file created after compilation?? is there any source code available in java to view the class file if so plz send me..
    thanks in adavance
    anu

    is there any simple method to view the class file
    created after compilation??
    is there any source code
    available in java to view the class file if so plz
    send me..I think the BCEL API allows you to analyze a class file...

Maybe you are looking for

  • Problem in using org.jdom.Parent in my EJB

    Hi All, I am using a code below to read a EBM and replace some of the node values in it. For that , initiallly, i want to check whether the XPATH class is working .. While i run this code in my SOAP-UI i get teh No class definition found exception fo

  • Windows 7 and Acrobat from an XP computer

    I  have had a desktop with Windows XP OS and now have switched to a desktop with Windows 7 OS. I had Acrobat 10.0 on the XP computer. I took the Adobe files off of that computer and put them on an external hard drive. Can I now put Acrobat 10.0 on th

  • Best Practice for Showing Videos in a Windows Application

    I am building a windows 8 application that has multiple articles.  Each article will have anywhere from 0-3 videos associated with it.  I was wondering where I could find some guidelines, best practices or examples about the how best to do this from

  • APEX 3.0 New Feature Overview= I wonder if this will be compatible with XE

    Oracle Application Express / 3.0 New Feature Overview http://www.oracle.com/technology/products/database/application_express/html/3.0_new_features_overview.html I wonder if this will be available for XE, perhaps the new version of XE will be able to

  • Interface used in loading flat file data into bw

    what is the interface used in loading flat files into the bw system.