Mahmut EFE
Mahmut EFE

Reputation: 5248

Importing JSON into an Netbeans project

I need to import JSON library into netbeans.

How can I do that?

I searched on internet and I found this article.

According to this article when I import

import org.json.simple.JSONArray;
import org.json.simple.JSONObject

that, it must be work. But unfortunately it didn't work. and I get an error:

Package doesnt exist

Thanks for your help.

Upvotes: 10

Views: 55759

Answers (5)

A Nichole
A Nichole

Reputation: 13

Or, instead of relying on the old version which uses the old import, use the newer version with the new import:

import com.github.cliftonlabs.json_simple.*;

For Netbeans, you can right click the project and go into Libraries to make sure the jar file is added into Classpath (not Modulepath). Press the '+' button to add it under that section by either by using a created library with the build jar and javadoc jar or, more simply, just adding the single jar file (json-simple-3.1.1.jar) directly to the classpath.

After doing this, the jar file should show up in the 'Libraries' folder under the project.

Upvotes: 0

Aman B.
Aman B.

Reputation: 148

Download jar from here : https://code.google.com/archive/p/json-simple/downloads And then add it to your "libraries" in netbeans.

Added this answer, because other answer didn't provide the above link, which is the easiest to download jar from.

Upvotes: 1

Navneet Kaushik
Navneet Kaushik

Reputation: 35

For this we have to add Class org.json.JSONObject which available in json-20131018.jar. We need to download this jar and add this jar to your buildpath.

for it in netbeans right click 'libraries' in the project list, then click add jar/folder.

Upvotes: 3

Gogo
Gogo

Reputation: 1

try add json-20131018.jar. This solved my problem. http://mvnrepository.com/artifact/org.json/json/20131018

Upvotes: 0

bidifx
bidifx

Reputation: 1650

As the article says you need to add the simple-json library to your project:

http://code.google.com/p/json-simple/

Upvotes: 6

Related Questions