Tuesday, November 29, 2011

Why do I get a duplicate name error when loading a JAR file?

The most common reason for a "java.lang.ClassFormatError: Duplicate name" error is that a .class file in the JAR contains a class whose class name is different from the expected name. So for example if you have a file called "a/B.class" and it contains a class called "B" or "a.X" instead of the class "a.B" then you will get this error.<br><br>The most common causes for this problem are either forgetting to include a "package a;" statement or having a "package" statement with the wrong name.
Category:Java Beans Interview Questions

No comments:

Post a Comment