File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes java.lang.ClassFormatError while loading class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "java.lang.ClassFormatError while loading class" Watch "java.lang.ClassFormatError while loading class" New topic
Author

java.lang.ClassFormatError while loading class

Nev Mehta
Greenhorn

Joined: Jan 09, 2007
Posts: 26
I am implementing the AbstractFactory pattern allowing outsiders to create Factories. I am reading the factory implementation name from a properties file, loading the factory class and using it to construct objects. Problem is that somewhere in my factory implementation when i'm trying to create an object of a task i get the following error.



Following is the GetUrl constructor, nothing fancy!



Any feedback on what might be happening here? Cross posted at http://stackoverflow.com/questions/12667377/java-lang-classformaterror-while-loading-class
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Did you perhaps transfer that .class file from another computer using FTP in ASCII mode?

Otherwise maybe you have a non-standard and buggy java compiler?

Or maybe you compiled with a newer version but are trying to run in an older JVM? (I would expect an error explicitly telling you that if this were the case, but maybe if you explicitly load the class yourself, that may not happen?)

Maybe you have some class named String that you wrote yourself that is getting confused with java.lang.String?

All we can tell here is that the ClassLoader considers the class to be corrupt. Without any information about how you compiled the class or what its superclass looks like or how it got to be available to your classloader or how you're loading it, it's hard to say anything definite.
Nev Mehta
Greenhorn

Joined: Jan 09, 2007
Posts: 26
There was some mismatch in the version of classes i was using. It works now. Thanks for your answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.ClassFormatError while loading class