0 votes
1 view
in Big Data Hadoop & Spark by (19.2k points)

I have created a jar file using the java file

javac -classpath /usr/local/hadoop/hadoop-core-1.0.3.jar -d /home/user1/dir Dictionary.java

/usr/lib/jvm/jdk1.7.0_07/bin/jar cf Dictionary.jar /home/hduser/dir

Now I have tried running this jar with various commands:

user1@ubuntu:~$ /usr/local/hadoop/bin/hadoop jar Dictionary.jar

Output:

Warning: $HADOOP_HOME is deprecated.

RunJar jarFile [mainClass] args...  

user1@ubuntu:~$ /usr/local/hadoop/bin/hadoop jar Dictionary.jar Dictionary

Output:

Warning: $HADOOP_HOME is deprecated.

Exception in thread "main" java.lang.ClassNotFoundException: Dictionary

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:423)

at java.lang.ClassLoader.loadClass(ClassLoader.java:356)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:264)

at org.apache.hadoop.util.RunJar.main(RunJar.java:149)

How can I run the jar in hadoop?

1 Answer

0 votes
by (42.6k points)

While creating the jar file, just mention the output as .class file instead of .java file. Here is what you can do:

javac -classpath /usr/local/hadoop/hadoop-core-1.0.3.jar -d /home/user1/dir Dictionary.class

...