Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

'bad class file', 'class file contains wrong class' error

843810Sep 2 2004 — edited Sep 25 2004
Hi. I have some .class files that i packaged into a single .jar file.
the directory structure inside that jar file is similar to this:

\ABC\the_class_i_want_to_access.class
\ABC\meta-inf\Manifest.mf

(as you can see, the class i want to access is inside the folder ABC)

and i named this jar file "jar.jar".

then i wrote some code that is supposed to access this jar file. Im positive that I have the classpath set correctly (i am using an IDE, JCreator. in jdk profiles i added an archive, pointing to jar.jar) I get this error:

bad class file: C:\...\jar.jar(ABC/the_class_i_want_to_access.class)
class file contains wrong class: the_class_i_want_to_access
Please remove or make sure it appears in the correct subdirectory of the classpath.
import ABC.the_class_i_want_to_access;
^

I am sure that my IDE is able to 'see' the jar file because jcreator is able to read the jar file, which i know because the popup dropdown menu (containing the list of classes) appears as i type 'ABC.'
*you probably know other IDE's like netbeans or forte have this feature too.

this is the way I use the jar in my code:

import ABC.the_class_i_want_to_access;

public class XYZ{
public static void main (String[] args) {
the_class_i_want_to_access sample = new the_class_i_want_to_access();
}
}


any help please??? the help topics on the net say that this error is related to classpath or something, i really tried to do it as they said, but i still have the error. thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2004
Added on Sep 2 2004
6 comments
3,237 views