How hadoop command works with javac?

0 votes

I was reading Apache mapreduce tutorial

I was able to run the example and get the desired result. However, I am not able to understand how it is asked that we should run following to compile the Java file.

$ bin/hadoop com.sun.tools.javac.Main WordCount.java

I went through the hapdoop command details. It partitioned all hadoop switches under General options, User commands, and Administrator commands. I didn't found where above javac command is given in hadoop command page.

Q. In fact actually I didn't get how above command works. I mean we usually specify hyphen-prefixed options in front of the commands. However, this above command asks to run javac in a way that I never saw before. I usually used to compile java files directly by javac filename.java. Why here is it asked to not do this way?

Q. Also there is .Main in com.sun.tools.javac.Main in the given command. What does this mean?

Aug 17, 2018 in Big Data Hadoop by Frankie
• 9,810 points
404 views

1 answer to this question.

0 votes
Javac is used for compiling your java code. If you notice the WordCount example, there are a lot of import statements which require you to add the corresponding jars in the classpath.

when you run hadoop com.sun.tools.javac.Main WordCount.java, hadoop would have already loaded all these dependent jar for compiling your program. You can test it by running javac WordCount.java and compiler would throw cannot find symbol error if you don't already have these required jar in your classpath.

With the Hadoop, you can set the compiler that you want it to use for compiling your code.

com.sun.tools.javac.Main is the programmatic interface for the Java Programming Language

When you execute bin/hadoop , with the first parameter as com.sun.tools.javac.Main and second parameter as WordCount.java, it uses the com.sun.tools.javac.Main to compile WordCount.java
answered Aug 17, 2018 by Neha
• 6,280 points

Related Questions In Big Data Hadoop

0 votes
1 answer

What is -cp command in hadoop? How it works?

/user/cloudera/data1 is not a directory, it is ...READ MORE

answered Oct 17, 2018 in Big Data Hadoop by Frankie
• 9,810 points
380 views
0 votes
1 answer

Hadoop: How to use Jps command with Sun JDK installed?

You can put JPS into your path ...READ MORE

answered Nov 9, 2018 in Big Data Hadoop by Omkar
• 68,480 points
273 views
0 votes
1 answer

The file exists before processing with hadoop command

Took session and it got resolved. READ MORE

answered Dec 18, 2017 in Big Data Hadoop by Sudhir
• 1,610 points
93 views
0 votes
1 answer

How to get started with Hadoop?

Well, hadoop is actually a framework that ...READ MORE

answered Mar 21, 2018 in Big Data Hadoop by coldcode
• 2,040 points
114 views
0 votes
1 answer

Moving files in Hadoop using the Java API?

I would recommend you to use FileSystem.rename(). ...READ MORE

answered Apr 15, 2018 in Big Data Hadoop by Shubham
• 13,350 points
966 views
0 votes
1 answer

Hadoop giving java.io.IOException, in mkdir Java code.

I am not sure about the issue. ...READ MORE

answered May 3, 2018 in Big Data Hadoop by Shubham
• 13,350 points
512 views
0 votes
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,800 points
3,566 views
+1 vote
11 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
18,351 views
+2 votes
1 answer

How to calculate Maximum salary of the employee with the name using the Map Reduce Technique

Please try the below code and it ...READ MORE

answered Jul 25, 2018 in Big Data Hadoop by Neha
• 6,280 points
660 views
0 votes
1 answer

How to create a project for the first time in Hadoop.?

If you want to learn Hadoop framework ...READ MORE

answered Jul 26, 2018 in Big Data Hadoop by Neha
• 6,280 points
109 views