-1

I have an issue , i need to use json for java and i try to import a it's library by this way :

import org.json.simple.JSONObject;

but it don't work , it says that the package org.json.simple does not exist .

any help please

(I use netbeans)

user3862568
  • 51
  • 1
  • 2
  • 4
  • What build tool are you using? MAven or ant? – skarist Jul 21 '14 at 23:34
  • hem , no one , in fact i don't know what are you talking about , i have searched and i ound that it has something to do with maven but i couldn't understund , please explain to me . – user3862568 Jul 21 '14 at 23:36
  • `org.json.` doesn't belong to standard Java packages. You need to download it and add to project classpath. – Pshemo Jul 21 '14 at 23:37
  • If you or not using maven or ant, your project still has a library/class folder. You need to put the json jar into your class/lib folder – skarist Jul 21 '14 at 23:37
  • i have tried to import the jar file as a library but it's not working too ?? – user3862568 Jul 21 '14 at 23:38
  • can you explain me how to do a clean import and what i have to add as syntax , thank you – user3862568 Jul 21 '14 at 23:39
  • Here you can find informations about how to add library/jar to your project in NetBeans http://stackoverflow.com/questions/5893349/java-how-to-add-library-files-in-netbeans – Pshemo Jul 21 '14 at 23:41

1 Answers1

2

Using a class that is not in part of the standard JAva library requires a bit more than just importing it by way of an import statement. The most direct way to accomplish this is to download a jar file to the local environment and add the jar to your build path. Alternatively, you can use a tool like Maven to manage your dependencies, but this is a bit more involved.

SimpleJSON can be downloaded from [here}(https://code.google.com/p/json-simple/downloads/list). Adding it to your build path depends on the IDE you are using, but instructions should be readily available on the interwebs.

Noticed you stated you used Netbeans

The Head Rush
  • 2,522
  • 2
  • 21
  • 39
  • thank you, i've done what you said but it steel not working , when i creat an object from a class of the imported jar , it's says that the class don't exist – user3862568 Jul 22 '14 at 00:20