0

When I try to run import org.json.simple.JSONObject;, I get an error saying

the type org.json.simple.JSONObject is not accessible

If I try to change it to import org.json.simple.*;, I still get an error saying the package is not accessible. I have included json-simple-1.1.1.jar in my classpath.

json-simple in my classpath

I also tried to make my project a Maven project and add it as a dependency there, but it was of no use.

The last comment in this mentions that compiling using Java 13 helped him, so I changed my execution environment to JavaSE-13, but that did not solve the issue either.

James Z
  • 12,209
  • 10
  • 24
  • 44
aayush-a
  • 1
  • 1
  • 3
  • As your jar file is in C drive. Might be a chance that it may have permission only for the Administrator. Can you try with changing location or you can put it in lib folder as well. – pratik patel Jun 23 '21 at 05:38
  • @pratikpatel tried running Eclipse as administrator to fix that, no success. Also, I haven't fragmented my drive, so I just have C. – aayush-a Jun 23 '21 at 05:52
  • If you have a `module-info.java` file delete it (or move the JAR from the classpath to the modulepath and in `module-info.java` add the required `requires ...` statement). – howlger Jun 23 '21 at 05:52
  • Running Eclipse as administrator is a pretty bad idea. The error says that you are doing something wrong, not that something is wrong with Eclipse. – howlger Jun 23 '21 at 05:57
  • @howlger deleting `module-info.java` worked. Thanks a ton for your help! – aayush-a Jun 23 '21 at 06:02
  • @howlger also, thanks for the tip. Won't be running it as admin from now. – aayush-a Jun 23 '21 at 06:05

1 Answers1

0

As suggested by @howlger, deleting the module-info.java file worked.

aayush-a
  • 1
  • 1
  • 3