Strange “java.lang.NoClassDefFoundError” in Eclips

2019-07-23 23:00发布

问题:

i am testing a J2me project when i run it is giving java.lang.NoClassDefFoundError: org/cdac/securitycore/storage/StorageBridge. I had included a jar file which contains StorageBridge.class even i checked the class path also my jar file compiled at 1.5 compilence & my application is building with 1.3 compilence is this the reason for creating a problem

回答1:

Perhaps you did not include the .jar correctly. Right click on your project and go to Build Path->Configure Build Path->Add external .jar. Hope that helps.



回答2:

I had the same problem once. It took me hours to figure it out...

From what I remember, Eclipse kind of "has" 2 classpaths: a compile classpath and a runtime classpath. I don't remember where exactly to access both, but I'm pretty sure it's somewhere in the project's properties. Make sure that your JAR file is added to both of them.



回答3:

java.lang.NoClassDefFoundError: org/cdac/securitycore/storage/StorageBridge. I had included a jar file which contains StorageBridge.class

But did it contain it as org/cdac/securitycore/storage/StorageBridge.class? and does that class contain the statement package org.cdac.securitycore.storage;? Getting either of whose wrong will cause this exception.



回答4:

You should try adding the jars by to the classpath in the following TWO ways:

(you_project) > Properties > Java Build Path > Libraries > Add External JARs...

AND (This is what fixed it for me)

Run > External Tools > External Tools Configurations > Classpath > User Entries > Add External JARs...



标签: java java-me