'bad class file', 'class file contains wrong class' error
843810Sep 2 2004 — edited Sep 25 2004Hi. 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.