5

I am getting this error:-NoClassDefFoundError wherever the code is using StringUtils class or methods .I have correctly added the jar files to the code and is not showing any kind of error in my code(Using Eclipse Indigo).

Is there any kind of point I am missing out. I have used this jar file in other projects but they worked properly.

Please help If any one is getting similar kind of problem?Thanks

Navdroid
  • 1,541
  • 3
  • 25
  • 52

5 Answers5

7

Yes, this because of your .jar file didn't import properly. Follow below steps -

  1. Place your .jar file in your project's libs folder .

  2. Import it into your project. And, GoTo project -> properties -> Java build path -> order tab.

  3. Check, whether your .jar file checked and placed in order of 1st. This is the main thing.

Hope these steps helps you. Have a look at below image -

enter image description here

Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
1

Note that the build classpath is different from the runtime classpath. You must add the required JARs to both.

It's one of the things I don't like in Eclipse...

EDIT: To add JARs to the runtime classpath: in Eclipse, double click the plugin.xml file associated with your project. On the Runtime tab there is a Classpath category. From there, you can add JARs to the runtime classpath.

Here is a screenshot to illustrate this:

plugin.xml runtime classpath

Radu Murzea
  • 10,724
  • 10
  • 47
  • 69
0

Are the jar files in a lib folder or a libs folder?

Newer SDKs require the jar files to be in a libs folder.

fasheikh
  • 419
  • 3
  • 19
0

I do not know how you execute your code, but it clearly means that the jar is not properly added to your classpath, especially if your code compiles in Eclipse.

Add it to your classpath -or re-check it is well added- when executing and it should work.

Jean Logeart
  • 52,687
  • 11
  • 83
  • 118
0

Right click on project, Select Build Path -> Configure Build Path and Select Libraries tab. Then with add Jars, add the jar in question.(if you are using eclipse)

Lazy Ninja
  • 22,342
  • 9
  • 83
  • 103