3

I have 16 Java files and I am trying to generate JAR files for the Hadoop ecosystem using the below command:

javac -classpath /usr/local/hadoop/hadoop-core-1.0.3.jar:/usr/local/hadoop/lib/commons-cli-1.2.jar  JsonV.java

JsonV.java is the class which has main function and this Java file calls other Java files. I am getting this below error, can anybody help me resolve this please?

JsonV.java:37: error: cannot find symbol
JSONObject obj = new JSONObject(tuple[i]);
                     ^ 
  symbol:   class JSONObject
  location: class Map
JsonV.java:37: error: cannot find symbol
                    JSONObject obj = new JSONObject(tuple[i]);
                                         ^
  symbol:   class JSONObject
  location: class Map
JsonV.java:43: error: cannot find symbol
            }catch(JSONException e){
                   ^
  symbol:   class JSONException
  location: class Map
JsonV.java:58: error: cannot find symbol
            }catch(JSONException e){
                   ^
  symbol:   class JSONException
  location: class Reduce
itoctopus
  • 4,133
  • 4
  • 32
  • 44
Sudhir Belagali
  • 370
  • 1
  • 7
  • 22

1 Answers1

0

If you use Java 7 & javax.json lib, you don`t need to include any external files. But if you use Java 6 & org.json lib, you have to add JAR explicitly. But it seems it works in eclipse. So I guess you are using jdk6 with hadoop. If you change it to jdk 7 for hadoop, the problem will be solved.

It works in eclipse because you configured your build path with jdk 7.

If you use maven, you have to mention the json lib dependencies in pom.xml file.

If you don't use maven, just copy paste your json lib jars in hadoop lib dir and restart hadoop. It will work.

Thanga
  • 7,811
  • 3
  • 19
  • 38
  • I dont have any other external jar files to parse Json data ,, I have only the JAVA files,,,and I stored all the jar files in single package – Sudhir Belagali Jan 29 '16 at 06:35
  • If you use Java 7 & javax.json lib, you don`t need to include any external files. But if you use Java 6 & org.json lib, you have to add JAR explicitly. But it seems it works in eclipse. So I guess you are using jdk6 with hadoop. If you change it to jdk 7 for hadoop, the problem will be solved – Thanga Jan 29 '16 at 07:22
  • sir i am using org.json ligrary with JDK7 , so it is working properly in eclipse,,,How to parse json data using javax.json lib – Sudhir Belagali Jan 29 '16 at 09:44
  • Hadoop 1 is compatible with JDK 6 for mapreduce jobs. So please run this with jdk 6 and org.json lib files – Thanga Jan 29 '16 at 11:04