Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Trouble with JSON imports  RSS feed

 
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I downloaded json-simple-1.1.1.jar and put it in my Netbeans folder. Added the file path to the classpath list. Still the imports are failing. The message on the last two imports is: org.jason.simple.JSONArray does not exist. What else do I need to do?

[/size]
 
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Mike Gauthier wrote:The message on the last two imports is: org.jason.simple.JSONArray does not exist. What else do I need to do?


Does your import specify jason or json?
 
Ron McLeod
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are the classes bundled in that jar:
org.json.simple.ItemList
org.json.simple.JSONArray
org.json.simple.JSONAware
org.json.simple.JSONObject
org.json.simple.JSONStreamAware
org.json.simple.JSONValue
org.json.simple.parser.ContainerFactory
org.json.simple.parser.ContentHandler
org.json.simple.parser.JSONParser
org.json.simple.parser.ParseException
org.json.simple.parser.Yylex
org.json.simple.parser.Yytoken
 
Mike Gauthier
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I had a typo in the error message.  
The error message says: package org.json.simple does not exist.

The import statements in the OP are correct
 
Ron McLeod
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To me it sounds like the jar is not in the buildpath.

I have never used NetBeans - is there a distinction between jar/libraries used at compile-time vs used at run-time?  Does NetBeans provide you a view of which classes are included in the buildpath?
 
Mike Gauthier
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:To me it sounds like the jar is not in the buildpath.

I have never used NetBeans - is there a distinction between jar/libraries used at compile-time vs used at run-time?  Does NetBeans provide you a view of which classes are included in the buildpath?



I'll do my best to try to answer these questions. The errors are highlighted while editing the file. I would guess that means it is detected at compile time.  The jar file is specified in the java Classpath area in the netbeans preferences. In the image below, it is the "Add JAR/ZIP" button used to add the path and the actual file path was browsed for not manually typed, so there is no typo in that.



I don't see a way to view the classes in the jar file, but I think a clue is the error message claims the library is missing, not one of the classes in it.

I'll be happy to provide any additional info that might help get this resolved.
 
Ron McLeod
Saloon Keeper
Posts: 2150
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just downloaded NetBeans and gave it a quick try - I didn't see the same error.



The library file you are adding is named json-simple-1.1.jar, not json-simple-1.1.jar.zip, right?
 
Mike Gauthier
Ranch Hand
Posts: 35
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is a jar file not a jar.zip.

I can see the problem with the image you posted. In the projects window there is a reference to the json-simple.1.1.jar file under libraries.  Mine didn't have that so I right-clicked on libraries and added the jar file as a new library.  BINGO!  problem solved.

I originally included the path to the jar file in the preferences as indicated in a web post I found. Obviously I was not adding the library in the correct place/way.

Thanks for posting the image that allowed me to see the problem.
 
What a stench! Central nervous system shutting down. Save yourself tiny ad!
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!