Results 1 to 8 of 8
Thread: Duplicate class error
- 07-11-2011, 08:40 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
Duplicate class error
hi there,
I'm a 1 day java programmer ! started with netbeans and right away faced a meaningless error:
1- created a new empty project,
2- added an empty java file to default package called GradeBook !
3- put this in the file:
public class GradeBook
{
public void displayMessage()
{
System.out.println("test");
}
}
and it gives the error "duplicate class: GradeBook"
when I change the name to anything else it gets right !
please sb tell me what the hell is this :D
- 07-11-2011, 08:55 AM #2
Hmm, normally its caused by having another file with the class in it within the same package. Do you have two GradeBook classes somewhere? Maybe in another file? If not I did some reading on it and it seems that some times Netbeans doesn't always properly rebuild itself or something to that effect. They suggest deleting all the unnecessary old files and trying it again. They also said to try using the "Clean and Build" option, now I don't know what that does because I don't use Netbeans I assume it filters out whatever isn't necessary for the program to run.
However since you're just starting, I suggest using a less helpful IDE. IDE's are helpful, too helpful in fact for people starting. While there are exceptions, it often allows the user to be lazy and take shortcuts instead of actually learning why certain things act the way they do. I suggest using Notepad++. It has a bunch of IDE functionality, the useful stuff like auto-indenting and syntax highlighting, without giving you so much power that you can easily skip out on the things you are trying to learn.
Using Notepad++ and the Command Prompt to handle your Java building will force you to get your hands dirty and learn more about the language.- Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
- +Rep people for helpful posts.
- 07-11-2011, 09:17 AM #3
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
thanks for the reply,
I tried almost all of them, even tried removing the whole project and directories on disk and recreating it, but it remains the same, also tried clean and build but no luck.
actually I'm new in java but not in programming and have a little experience in .net programming and worked with MS Visual IDE and want a powerfull IDE to write java codes, I'm trying to find the problem and fix it not easily switching my IDE .
btw, I don't have any duplicated file so maybe I should ask the question in netbeans section :D
- 07-11-2011, 10:44 AM #4
Moved from 'New to Java' and locked the second thread.
db
- 07-11-2011, 10:45 AM #5
It deletes the entire content of the build and dist folders (clean) and then regenerates them (build).the "Clean and Build" option, now I don't know what that does
db
- 07-11-2011, 10:49 AM #6
Do some detective work. Use another class name, then in that class declare a variable of type GradeBook then right-click / 'Fix Imports'. See what class is imported. Of course, if there's really a duplicate class in a default package, that can't be imported.
Check that you don't have unwanted stuff in your jre/lib/ext folder. Have you been saving any of your own work in that folder, or any folder under the jdk program folder?
db
- 07-11-2011, 12:32 PM #7
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
I tried removing the whole project and recreated it again and it worked this time, now I can't test your solution but I remember it for similar future problems,
thank you
- 06-28-2012, 05:02 PM #8
Member
- Join Date
- Jun 2012
- Posts
- 1
- Rep Power
- 0
Re: Duplicate class error
I was getting this same issue with Jax-ws client. It was caused by a different build error. I cleaned up the code to remove the other build errors, but still had the duplicate class issue until I did a clean and build. I believe this is because this causes the Generated Source to be rebuilt.
Similar Threads
-
org.hibernate.DuplicateMappingException: Duplicate class/entity mapping project
By Ed in forum JDBCReplies: 4Last Post: 05-13-2011, 10:04 PM -
Eclipse Compile Error: Call validateValue(Class<T>, String, Object, Class<?>...)
By Tomshi in forum EclipseReplies: 0Last Post: 03-27-2011, 05:49 AM -
Error if array contains duplicate integers
By lithium002 in forum New To JavaReplies: 4Last Post: 12-05-2009, 08:58 AM -
DOnt know if 1st post if did, I am VERY sorry for duplicate post. I have error messg
By afisher300 in forum New To JavaReplies: 3Last Post: 05-04-2009, 03:15 AM -
Error in class
By ai_2007 in forum Advanced JavaReplies: 1Last Post: 07-09-2007, 04:06 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks