Unable to generate jar file for Hadoop

一笑奈何 提交于 2019-12-10 20:29:15

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/35030016/unable-to-generate-jar-file-for-hadoop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!