1

I'm trying to compile some Java code in Ubuntu 16.04. when i compile, the following error occurs.please tell me the steps to install json for java and set it as classpath so that i can compile without the -cp.

awd@awd-HP-ProBook-450-G3:~/Desktop/thin-mach-java /javajson$ javac -cp /usr/share/java/java-json.jar psp1.java
psp1.java:1: error: package org.json.simple does not exist
import org.json.simple.*;
^
psp1.java:5: error: cannot find symbol
JSONObject jsonObject =new JSONObject();
^
symbol:   class JSONObject
location: class psp1
psp1.java:5: error: cannot find symbol
JSONObject jsonObject =new JSONObject();
                           ^
symbol:   class JSONObject
location: class psp1
3 errors
0

That error means that you did not add the library org.json.simple to your project. If you are using maven, add the dependency:

<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1.1</version>
</dependency>

Otherwise download the package and add it to the project manually. Here you can download it http://www.java2s.com/Code/Jar/j/Downloadjsonsimple11jar.htm

1
  • but im not using any ide i just compiled my program on terminal. and i included the .jar file in classpath correct of that im sure. – awadhesh14 Aug 11 '16 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.