Failed to create jar file for Hadoop

I have 16 Java files, and I'm trying to create JAR files for the Hadoop ecosystem using the following 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 a class that has a core function, and this Java file calls other Java files. I get this below error, can someone help me solve 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 
+2
source share
1 answer

If you are using Java 7 and javax.json lib, you do not need to include any external files. But if you are using Java 6 and org.json lib, you must explicitly add the JAR. But it seems to be working in an eclipse. Therefore, I assume that 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 the build path using jdk 7.

If you are using maven, you must specify json lib dependencies in the pom.xml file.

If you are not using maven, just copy your json lib jars to hasoop lib dir and restart hasoop. He will work.

0
source

Source: https://habr.com/ru/post/1205890/


All Articles