Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing JSON into an Eclipse project

I'm an aspiring Java programmer looking to use JSON in a project. I was following a programming tutorial (from a book) which asked me to import JSON into my project by using the following line:

import com.google.appengine.repackaged.org.json.JSONArray;  

But this produced an error, so I replaced it with this line:

import org.json.JSONArray; 

This also produces a (different) error:

The import org.json cannot be resolved

I think the problem is that I don't actually have the JSON library in my Eclipse workspace. How can I do this, so I can use the JSONArray? I found the website for JSON, but am not sure what to download or how or where to install it:

http://json.org/java/

like image 609
Asher Walther Avatar asked Jan 25 '12 03:01

Asher Walther


People also ask

Can I open JSON file in eclipse?

json and tweak. json files for the plug-in. If an item is available for editing in Eclipse, you can double-click to open it.


2 Answers

Download the ZIP file from this URL and extract it to get the Jar. Add the Jar to your build path. To check the available classes in this Jar use this URL.

To Add this Jar to your build path Right click the Project > Build Path > Configure build path> Select Libraries tab > Click Add External Libraries > Select the Jar file Download

I hope this will solve your problem

like image 198
Ramkumar Murugadoss Avatar answered Sep 27 '22 23:09

Ramkumar Murugadoss


You should take the json implementation from here : http://code.google.com/p/json-simple/ .

  • Download the *.jar
  • Add it to the classpath (right-click on the project, Properties->Libraries and add new JAR.)
like image 25
Jeremy D Avatar answered Sep 27 '22 22:09

Jeremy D