Tuesday, 9 June 2015

java.lang.NoClassDefFoundError: org/json/JSONObject

I was getting the above error even after adding the required jar (java-json.jar) to the library.

I have followed the below steps to add this jar to the library.

Click on Project -> Properties -> Java Build Path (on left panel) -> select Libraries Tab -> click on Add External JARs  and import the jar.

So in order to avoid the above problem I add the above jar to Deployment Assembly as well.

Click on Project -> Properties -> Deployment Assembly (on left panel) - > click on Add -> Select Java Build Path Entries -> select the Jar.

Not sure whether it is the good approach or not but it solved my problem.

Another way to avoid these dependency errors is to use Maven.

1 comment: