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.

Similar Messages

  • .class Files with "$X" extensions

    Hi everybody,
    when I deploy my App, some confusing .class files are generated by my JDev (10.1.3.3) ...
    In my Project I declare a Class named
    - JClientDesktopManager.java
    This is compiled to two .class files:
    - JClientDesktopManager.class     
    - JClientDesktopManager$1.class
    Whats that strange class with "$1"?
    Should I care about about it? - it seems randomly...

    Hi!
    Theses files house anonymous inner classes, a standard Java mechanism.
    Whenever you write something like:
    ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { <your code here> }};or
    JTable table = new JTable() { public boolean isEnabled() { <your code here> }};you create in fact new (anonymous) inner classes. These classes have no name (hence "anonymous"), they are just numbered.
    For more background you could just Google for "anonymous inner class".
    Sascha

  • 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

  • Automating the process of comparing two PDF file with the help of QTP(Automation Testing Tool)

    Can anybody help me with comparing the two pdf files with the help of QTP.I have Adobe Acrobat installed on my system and i have access to the API.
    Thanks,
    Varun Saini

    I want to find out more about QTP and API. Maybe that is what I want to compare two mechanical drawings for differences between them. (see “More than one pdf file in one window”. Is that what you are looking to do? 9Not necessarily mechanical drawings but some other pdf).

  • I can't open two eml files with Thunderbid

    I want to open two .eml files with Thunderbid. When I try to do it, I can open the first, but when I try to open the second Thunderbird doesn't do it.

    It sounds like the files that aren't working are likely corrupt or perhaps not properly designated as .eml files. When you say "Thunderbird doesn't do it" do you mean Thunderbird doesn't launch, or do you mean it tries to open the file and returns an error? The error could be helpful in the latter case, as could information about where the file came from. In the former case, FYI, when I drag attached .eml files (from e-mails forwarded as attachments) to my desktop, they are named "Inbox" (as opposed to Inbox.eml). I rename them to add the .eml and then I can open them with Thunderbird, but otherwise I will be prompted by Windows for what to do with them.

  • Passing variables and methods between two class files

    I created two simple programs to see what I can learn about how separate class files work together.
    There are two files, Alpha.java and Beta.java. Both are located in the same folder.
    Here�s Alpha.java:
    ********* Alpha.java *********
    public class Alpha {
    public int alphaInt;
    public void alphaMethod() {
    System.out.println("This is Alpha's alphaMethod.");
    ******** End Alpha **********
    Here�s Beta.java
    ******** Beta.java ***********
    public class Beta {
    public static void main() {
    Alpha a = new Alpha();
    a.alphaInt = 10;
    System.out.println(The value of alphaInt is " + a.alphaInt);
    a.alphaMethod();
    ******** End Beta ***********
    Alpha compiles fine. Beta does not compile and I get this error:
    �Exception in thread �main� java.lang.NoSuchMethodError: main�
    My first problem to solve is to get Beta to compile. After that I should be able to run it from the command line and get something like this as output:
    �The value of alphaInt is 10�
    �This is Alpha�s alphaMethod.�
    Would some kind people please help me with this?
    TIA,
    Logan

    That was easy, and it confirms what I thought should happen. Now for the real question:
    Alpha and Beta are servlets in a package called abClasses. Alpha starts out like this:
    package abClasses;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import java.util.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class Alpha extends HttpServlet {
    Beta is the same, except for the name of course.
    Alpha creates a Connection variable, and Beta is going to use it. But when I try to compile Alpha I get an error that says this:
    cannot resolve symbol
    symbol: class Alpha
    location: abClasses.Beta
    Alpha a = new Alpha();
    Any suggestions on why what we did in the simple Alpha and Beta programs won't work in the Alpha and Beta servlets?
    You are appreciated,
    Logan

  • 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.

  • Se development kit (jdk 6) problem creating class file with HelloWorldApp

    I downloaded the java SE Development kit (JDK 6) with Java FX SDK and used the download manager from Java web site, the program downloaded the
    jdk-6u13-javafx-1_1_1-windows-i586 icon to my desktop and the java program to
    C\Program Files\Java\jdk1.6.0_13
         Jre1.5.0_05
         Jre1.6.0_03
         Jre6
    I then created a Java source file which was HelloWorldApp.java. and typed in the Hello World Code as requested I saved it to
    C\Documents and Settings\Compaq_owner\Java.
    Then I try to compile my source file into a .class file and get stuck as I am told to open a command window which I do through, start\allprograms\accessories\command promt.
    My command window says C:\Documents and Setting\Compaq_Owner>
    I am told to compile my source file and I must change my directory in the command window to the directory where my file is located.
    I type after the existing promt, cd C:\java and also tried, cd C:\Documents and Settings\Compaq_Owner\Java\HelloWorldApp. And was told both times the system cannot find the path specified
    I typed dir after the promt and can see the java directory there in the list, but have I placed my HelloWorldApp File in the wrong place what is wrong please help I cannot get off the ground
    Kind regards pete

    petefizz wrote:
    I then created a Java source file which was HelloWorldApp.java. and typed in the Hello World Code as requested I saved it to
    C\Documents and Settings\Compaq_owner\Java.Then the full path to your HelloWorldApp.java file is: C\Documents and Settings\Compaq_owner\Java\HelloWorldApp.java.
    Then I try to compile my source file into a .class file and get stuck as I am told to open a command window which I do through, start\allprograms\accessories\command promt.
    My command window says C:\Documents and Setting\Compaq_Owner>
    I am told to compile my source file and I must change my directory in the command window to the directory where my file is located. You file is located in the directory, C\Documents and Settings\Compaq_owner\Java
    I type after the existing promt, cd C:\java and also tried, cd C:\Documents and Settings\Compaq_Owner\Java\HelloWorldApp. And was told both times the system cannot find the path specifiedcd stands for Change Directory. You want to change to the directory where your .java file is. You can not use a path that ends in a file because a file is not a directory.
    You may need to put C\Documents and Settings\Compaq_owner\Java inside double quotes, "C\Documents and Settings\Compaq_owner\Java" I think newer versions of Windows will not require the double quotes.

  • Package class files with bpel suitcase

    Hello,
    Is it possible to package java classes which are invoked through WSIF along with the BPEL Suitcase generated by bpelc?
    I've noticed that when generating and deploying the suitcase using JDeveloper (10.1.3.x) - the class files are compiled to the output directory and packaged in the suitcase, but when I run the same build.xml via Ant (ant deploy-process), the class files are missing in the output directory and thus missing in the suitcase.
    I'm using BPEL 10.1.3.
    So, the question is what causes the difference and how can I achieve packaging the class files using Ant without Jdeveloper.
    Any help is most appreciated.
    Best regards,
    Harm

    Well, I found the answer myself after decompiling com.collaxa.cube.ant.taskdefs.Bpelc.class..... because documentation or manuals about the ant tasks where not available.
    Apparently, the bpelc tasks can have nested elements of type zipfileset. (See the Ant documentation about this type). In here is the solution.
    Here is a how-to:
    You have to change the jdeveloper generated build.xml.
    @ 1st you have to add a "javac" task (if not already there) like below, and add it to build.xml:
    <target name="java-compile" description="Compile Java source files">
    <echo>
    | Compiling java source files
    </echo>
    <javac destdir="${process.dir}/output"
    encoding="UTF-8" source="1.5" target="1.5">
    <src path="src"/>
    </javac>@ 2 Extend target "process-deploy" to depend it on target "java-compile". It is important that the java gets compiled before the bpelc is executed. Like so:
    <target name="process-deploy"
    depends="validateTask, java-compile, compile, deployProcess, deployTaskForm, deployDecisionServices" />@ 3 Change the bpelc task by including a nested classes element that includes your class files, like so:
    <bpelc input="${process.dir}/bpel/bpel.xml" out="${process.dir}/output"
    rev="${rev}" home="${bpel.home}">
    <classes dir="${process.dir}/output" includes="**/*.class"/>
    </bpelc>When you run target "process-deploy", the class files are added to the bpel suitcase.
    Harm

  • Launching Class File with URLClass Loader

    Before anyone flames me I want toe explain that I have searched the forums and the deveolper section and though I have found a lot of useful information I am still not sure what I am missing. It may be something small that I am just over looking so if someone could look over my code I would greatly appreciate it.
    I am making a class with a URLClassLoader with which I can launch another java class file. At this stage the class merely takes the path to the file and the name of the class file as command line arguements. This attempt was just a test so I could implement it into another application. The code itself was almost taken completely from a trial on the developer part of this site. The issue I am running into is that nothing appears to launch. I can run the app from the command line and pass the arguements, however the class file I pass never appears to launch. I do not receive any errors at all. Any ideas what I am missing or doing wrong?
    import java.net.*;
    import java.io.*;
    public class Launcher
         public static void main(String args[])
              try
                   File daPath = new File(args[0]);
                   System.out.println(daPath.toString()); //output
                   URL daPathURL[] = {daPath.toURL()};
                   ClassLoader daLoader = new URLClassLoader(daPathURL);
                   Class daClass = daLoader.loadClass(args[1]);
                   System.out.println("loaded " + daClass.toString()); //output
                   Object daObj = daClass.newInstance();
                   System.out.println("new instance"); //output
              }catch(MalformedURLException e){
                   e.printStackTrace();                    
              }catch(ClassNotFoundException e){
                   e.printStackTrace();
              }catch(InstantiationException e){
                   e.printStackTrace();
              }catch(IllegalAccessException e){
                   e.printStackTrace();
    }

    Are we talking about a new main class here with an main method.
    To run such a class you don't instaciate it (it does that itself). You need to load the class then invoke the main method.
    Something like:
    String[] otherArgs = String[args.length - 2]; // copy args except first two
    System.arrayCopy(args, 2, otherArgs, 0, args.lenght - 2];
    Method mainMethod = dClass.getMethod("main", new Class[]{String[].class});
    mainMethod.invoke(null, new Object[]{otherArgs});

  • How can i compare two excel files with different no. of records.

    Hi
    I am on to a small project that involves us to compare two excel files. i am able to do it but am struck up at a point. When i compare 2 different .csv files with different no. of lines i am only able to compare upto a point till when the number of lines is same in both the files.
    Eg. if source file has 8 lines and target file has 12 lines. The difference is displayed only till 8 lines and the remaining 4 lines in source lines are not shown.
    Can you help me in displaying those extra 4 lines in source file. I am attaching my code snippet below..
    while (((strLine = br.readLine()) != null) && ((strLine1 = br1.readLine())) != null)
                     String delims = "[;,\t,,,|]";
                    String[] tokens = strLine.split(delims);
                    String[] tokens1 = strLine1.split(delims);
                   if (tokens.length > tokens1.length)
                    for (int i = 0; i < tokens.length; i++) {
                        try {
                            if (!tokens.equals(tokens1[i])) {
    System.out.println(tokens[i] + "<----->" + tokens1[i]);
    out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + tokens1[i]);
    out.println();
    sno++;
    } catch (Exception exception)
    out.write(sno + " \t" + lineNo1 + " \t\t" + tokens[i] + "\t\t\t\t" + "");
    out.println();
    Thanks & Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    A CSV file is not an Excel file.
    But apart from that your logic makes no sense.
    If the 2 files are of different sizes the files are different by definition, so further comparison isn't needed, you're done.
    If you want to compare individual records, you need to compare all records from one file with all records from the other, unless the order of records is important in which case your current system might work.
    That system however is overly complicated for comparing CSV files.
    As you assume a single record per line, and if one can assume those records to have identical layout (so no leading or trailing whitespace in or between columns in one file that's not in the other) comparing records is simply a matter of comparing the entire lines.

  • Using class files with applets

    I've converted a college project, a calculator, into an applet for a website resume. When the html file that loads the applet is opened on a machine with a JVM, the applet works fine. When I tested it on a machine that doesn't have a JVM, the applet wouldn't open.
    I'm assuming its because I'm using methods from classes such java.math, java.awt and java.awt.event. I wanted to try to include the neccessary class files into a .jar file that could be included into the archive attribute. Would this work? and also, where can I actually find these files so that I can put them into a jar file. For example, which directories would I look at to find them? I'm on Mac OS 10.3.7.
    Even with a search utility,I can't find the specific files with I'm looking for.
    Any help is greatly appreciated

    Hi,
    It doesn't matter that you have used classes in the packages java.math etc. The application will never run if there isn't a JRE installed for the web browser. I think most people usually puts a script on the html page which detects if a JRE is installed, and directs users to the download page if there is no JRE.
    Kaj

  • Read two lvm files with different length

    I'm trying to read to same graph two different measurements with same starting point, starting point is OK.
    But when the shorter file is coming to the end the VI stops with following message:
    "Possible reason(s):
    LabVIEW:  End of file encountered.
    =========================
    NI-488:  Invalid argument or arguments to function call."
    How can I come over this and get both measurements into same graph in their full length with same starting point?
    PS I have attached the VI file, a short and a long measurement file. Changed the file extension from LVM to TXT
    Attachments:
    Read_duo.vi ‏128 KB
    SE1100_ny_1.txt ‏249 KB
    SE1100_ref_1.txt ‏468 KB

    Hi,
    Apprently your LabVIEW is set with the option "enable automatic error handling", you can change this in tools >> options block diagram untick the option.
    Doing this will only get ride of the dialog when the error occurs but not get read of the error.
    So you are reading your files chunk by chunk in your while loop, so at some point you will get to the end of your files, when you do the VI you are using return an error 4 "end of file reached", from here you have different possibilities, if you want to be able to read files that have different length, here is a quick way to ignore the "end of file" error on both files independantly.
    Hope this helps
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"

  • Working With Two External Files With T-SQL Commands

    Hi friends,
    In a VSTO Excel AddIn of mine I have come across a need to use T-SQL commands before bringing the dataset on the activesheet, derived from two tables in the shape of external CSV files. However,
    since using SQL Express in this regard requires connection to a server. With Visual Studio as well as SSMS installed on my laptop I'm able to use the said facility but I am unable to distribute such an addin to other team members not having any of the studios
    installed nor access to any server.
    Is there any way to use the similar features on the users' side?
    In other words, how to develop a macro, for example, in which I could consider two CSV files as two different tables as in a database, and carryout some T-SQL functions/commands on the same like:
    UNION of first three columns from both the tables;
    Creating a temporary table with the DISTINCT sets of the said three columns; and
    Then carryout LEFT JOINS between the new table and the earlier two tables;
    to derive a simple comparative dataset?
    Looking forward for you experts' valuable advices in this regard.
    Thanx in advance.
    Thanx in advance, Best Regards, Faraz A Qureshi

    Hi FARAZ,
    As with Excel files, you can also use Odbc driver to connect to CSV files. As long as the user's machine installs the ODBC driver, you can OdbcConnection to connect to the CSV files.
    The sample code to manimulate CSV files with ODBC driver(C#):
    string connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)}; Dbq=C:\; Extensions=asc,csv,tab,txt;";
    using (OdbcConnection conn = new OdbcConnection(connectionString))
    conn.Open();
    string sql = "SELECT u.UserName,u.Age,c.Phone,c.Address FROM user.csv u left join contact.csv c on u.Id=c.UserId";
    using (OdbcCommand cmd = new OdbcCommand(sql, conn))
    But if you want to publish the Add-in to the user's machine, you still need to install the .Net Framework and the VSTO runtime to support the Add-in.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • 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

Maybe you are looking for

  • Using elements 9 as external editor

      Hi, I bought elements 9 today. I have all my pictures organized in aperture 3. I want to use elements as an external editor. I selected elements as the external editor in aperture 3, but when I try to edit a picture using the external editor via ap

  • Call Library Function with C structure

    I have been given a MS C++ DLL that I need to call from LabVIEW. The input (and output) to the DLL are pointers to "C" data structures. The LabVIEW "Call Library Function" VI allows you to add input parameters and define their type (I.e. Numeric, Arr

  • LR 4 Edit in PE 10

    Using "edit in - PE 10", making changes and re-saving back to LR 4 the images do not show up in the catalog. Instead I have to import the changed PSD file. Is this normal or am I missing something?

  • Sharepoint Authentication with OWIN

    Hello, I am working on Publishing site on SP 2013 with Object Model. I tried to use OWIN Middleware to authenticate the customer. The steps I follow are: -> deployement of OWIN assemblies in the web application: OK -> Startup Class: OK public void Co

  • Thumbnail gallery, low res on mobile?

    Hello, i have made a gallery in Muse, but when i view it on a mobile the images aren't sharp clear enough.. I have also try the HD setting.. but i still ain't smiling ;-(... Does the thumbnail gallery showing a low res? Home