Results 1 to 9 of 9
  1. #1
    bruceaj is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Duplicate Class Error Message

    I am using NetBeans for development and I am getting an error message at my main class indicating that my main class is a "Duplicate Class". I even deleted the offending class and recreated if from scratch. I still get the "Duplicate Class" error message.

    I did a "clean and build" and the build is successful.

    As soon as I try to run the project, a dialog pops ups saying "One or more projects were compiled with errors". Ignoring the error and running project causes it to die immediately with

    "java.lang.VerifyError: (class: Census/CensusReports, method: <init> signature: ()V) Constructor must call super() or this()
    Could not find the main class: Census.CensusReports. Program will exit.
    Exception in thread "main" Java Result: 1"

    Adding super() to the constructor does nothing. The same error as above appears.


    What do I need to do to get rid of the error message?

    Thanks for the help.
    Last edited by bruceaj; 09-08-2011 at 09:59 PM. Reason: Add more information

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default Re: Duplicate Class Error Message

    Is it possible for you to try compiling the program outside of the IDE with the javac command and see what errors ou get?

  3. #3
    bruceaj is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: Duplicate Class Error Message

    I've never done that but I'll try... I did check and the javac cmd is available from a cmd prompt. I'll see what I can do.

    This is going to take some time. I have a total of 6 files in the project, which includes the one that is giving me the problem. Also, I have an external library that I'll need to point to, somehow, with the javac cmd.
    Last edited by bruceaj; 09-08-2011 at 10:25 PM. Reason: More information

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: Duplicate Class Error Message

    Do you have 2 classes with the same name? What are the 6 classes you have?

  5. #5
    bruceaj is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: Duplicate Class Error Message

    I haven't been able to figure how to tell the compiler where my common Library is. I cd to the directory above my source code and issue: javac Code\*.java and that complies my base code, but I do have errors because it doesn't know where my own common Library is.

    Suggestions on how to use the javac command. I keep Googling. Maybe I'll find what I need. I'm sure it must be out there somewhere.

    Thanks...

    Bruce

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default Re: Duplicate Class Error Message

    Look at using the -classpath option to point to the needed jar files

  7. #7
    bruceaj is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: Duplicate Class Error Message

    Quote Originally Posted by Junky View Post
    Do you have 2 classes with the same name? What are the 6 classes you have?
    Looking under the NetBeans "Files", I find
    Census1930.class
    Census1920.class
    Census1910.class
    Census1900.class
    Census1880.class
    CensusReports.class

    In the source code, CensusReports.class is the one that NetBeans had flagged as duplicate.

    In searching the code, I have not been able to find another CensusReport.class. The project is small enough that I should be able to find any duplicate class. I suspect that NetBeans has some residual stuff somewhere that needs to be deleted but I'm fairly new to NetBeans/Java and not sure what I can manually delete safely.

    I removed CensusReports.class from the project and did a clean/build. Compile errors reported that it couldn't find CenusReports.

    I created a NEW CensusReports.class and the message "duplicate class: Census.CensusReports" came back.
    Last edited by bruceaj; 09-09-2011 at 04:47 PM. Reason: Add additional information

  8. #8
    bruceaj is offline Member
    Join Date
    Sep 2011
    Posts
    9
    Rep Power
    0

    Default Re: Duplicate Class Error Message

    Still haven't figured out where the duplicate class problem is but I created a completely new project and copied all my classes into it, included the class that gave me the error message.

    Guess what. All is good. The new project compiles and runs with NOT errors.

    So, I'm guessing it's some sort of bug in NetBeans that left some residual stuff around. With the new project running, I "MIGHT" take the time to delete files from the original and see if I can find the culprit.

    Thanks to all with the suggestions..

    Bruce

  9. #9
    duckStart is offline Member
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    0

    Default Re: Duplicate Class Error Message

    Hi, I had the same problem and i am using the java.sql connection for local database. I also couldn't figure out the solution and at the end recreate the project and copy the code in the new classes. Thanks for the solution.

Similar Threads

  1. Duplicate class error
    By hamedy in forum NetBeans
    Replies: 7
    Last Post: 06-28-2012, 05:02 PM
  2. Replies: 2
    Last Post: 10-02-2010, 02:13 AM
  3. Semantic Error: Message not understood by class
    By JVassie in forum New To Java
    Replies: 5
    Last Post: 04-15-2010, 02:39 PM
  4. Replies: 1
    Last Post: 02-15-2010, 10:32 PM

Posting Permissions

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