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.
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?
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.
Re: Duplicate Class Error Message
Do you have 2 classes with the same name? What are the 6 classes you have?
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
Re: Duplicate Class Error Message
Look at using the -classpath option to point to the needed jar files
Re: Duplicate Class Error Message
Quote:
Originally Posted by
Junky
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.
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
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.