问题
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