Eclipse plugin: java.lang.NoClassDefFoundError
You need to add the jar files in your build.properties bin.includes entry. Also, in your MANIFEST.MF file, they need to be added in the Runtime->Classpath list (corresponds to the Bundle-ClassPath entry in the MANIFEST.MF).
Edit: if you just put them in the referenced libraries, the OSGi system will not be aware of that fact.
java.lang.NoClassDefFoundError when I add external JARs using Eclipse IDE
Actually I figured out that I add the external jar file to the module path but not the class path. So the Eclipse IDE didn't throw any error but at run time Java threw java.lang.NoClassDefFoundError
. After I have added the jar to the class path, it's OK. It's in: right click the project -> Properties
-> Java Build Path
-> Libraries
-> Classpath
-> Add external JARs
.
Suddenly NoClassDefFoundError in Eclipse (and only there)
This is what finally (after several hours) worked for me:
I removed all the stuff eclipse stored in the workspace folder - more precisely, basically every folder starting with a dot. (Probably only the .metadata folder would have sufficed, but I don'thave the nerve to examinate this more deeply.)
Apparently, something about the classpath is stored permanently in the workspace, so switching back to an earlier version didn't solve my problem.
Just a warning: This solution did work, but cleaning up the workspace like this will let eclipse forget virtually everything!
The dreaded java.lang.NoClassDefFoundError
A NoClassDefFoundError
basically means that the class was there in the classpath during compiletime, but it is missing in the classpath during runtime.
In your case, when executing using java.exe
from commandline, you need to specify the classpath in the -cp
or -classpath
argument. Or if it is a JAR file, then you need to specify it in the class-path
entry of its MANIFEST.MF
file.
The value of the argument/entry can be either absolute or relative file system paths to a folder containing all .class
files or to an individual .jar
file. You can separate paths using a semicolon ;
. When a path contains spaces, you need to wrap the particular path with doublequotes "
. Example:
java -cp .;c:/path/to/file.jar;"c:/spacy path/to/classes" mypackage.MyClass
To save the effort of typing and editing the argument in commandline everytime, use a .bat
file.
Edit: I should have realized that you're using an Unix based operating system. The above examples are Windows-targeted. In the case of Unix like platforms you can follow the same rules, but you need to separate the paths using a colon :
and instead of an eventual batch file, use a .sh
file.
java -cp .:/path/to/file.jar:"/spacy path/to/classes" mypackage.MyClass
Related Topics
How to Add Image in a Textview Text
Retrofit2 Android: Expected Begin_Array But Was Begin_Object at Line 1 Column 2 Path $
Recyclerview Item Click Listener the Right Way
What Is Shareduserid in Android, and How Is It Used
Android.Util.Androidruntimeexception: Requestfeature() Must Be Called Before Adding Content
Create a New Textview Programmatically Then Display It Below Another Textview
Background Service for Android Oreo
Database Not Copying from Assets
Android Studio Debugger Highlights the Wrong Lines
Why I Cant Use the Populateviewholder Override Method
JSONparser from Androidhive Tutorial, Nosuchmethoderror in Defaulthttpclient
How to Pass a String from One Activity to Another
Onclicklistener Not Responding
How to Check If Current Thread Is Not Main Thread
How to Change Color of the Back Arrow in the New Material Theme