einstein
einstein

Reputation: 13850

Add JSON class folder and import in Java and Eclipse as IDE

I'm new to Java and have searched for quite a time now on the internet to a solution to my problem. I'm trying to add the JSON classes folder to my web app. The folder for JSON classes can be retrieved from this link: http://www.json.org/java/. What I did is copied the folder to my WEB-INF/lib folder and added that folder to my classpath by rightclick on Libraries -> Build Path -> Configure Build Path -> Add Class Folder. Ok so far so good! Btw, is this the right procedure for adding class folders? But what shall I type in a new Java class?

I have tried import JSONArray, but it is not working. Could you please give the right syntax for importing the JSON classes?

Upvotes: 2

Views: 12554

Answers (2)

justLearning
justLearning

Reputation: 1

If you wana to use servlets in tomcat you also have to copy the org.json.jar to lib in tomcat folder. If not eclipse will not give you any error but tomcat will.

Upvotes: 0

Jeremy
Jeremy

Reputation: 22435

You need to use the fully-qualified class name, which includes the package:

import org.json.JSONArray;

(And yes, that is the correct way to add classes/jars to your project's classpath in Eclipse.)

Upvotes: 3

Related Questions