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,830 points
2,647 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,300 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,830 points
4,194 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
• 69,220 points
1,986 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,570 points
1,059 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,090 points
1,208 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,490 points
2,695 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,490 points
2,569 views
+1 vote
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
• 11,380 points
11,078 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
109,076 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,300 points
5,688 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 27, 2018 in Big Data Hadoop by Neha
• 6,300 points
1,186 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP