[英]How hadoop command works with javac
I was reading Apache mapreduce tutorial 我正在阅读Apache mapreduce教程
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.
但是,我无法理解如何运行以下命令来编译Java文件。
$ bin/hadoop com.sun.tools.javac.Main WordCount.java
$ bin / hadoop com.sun.tools.javac.Main WordCount.java
I went through the hapdoop command details . 我查看了hapdoop命令的详细信息 。 It partitioned all hadoop switches under General options, User commands and Administrator commands.
它在常规选项,用户命令和管理员命令下对所有hadoop开关进行了分区。 I didnt found where above
javac
command given in hadoop command page. 我没有找到hadoop命令页面中给出的上述
javac
命令的位置。
Q . 问: In fact actually I didnt 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.
但是上面的命令要求以我以前从未见过的方式运行javac。 I usually used to compile java files directly by
javac filename.java
. 我通常用
javac filename.java
直接编译java文件。 Why here it is asked to not do this way? 为什么在这里被要求不这样做?
Q . 问: Also there is
.Main
in com.sun.tools.javac.Main
in the given command. 在给定命令中
com.sun.tools.javac.Main
中还有.Main
。 What does this mean? 这是什么意思?
I know I must be missing something very basic understanding about how commands works in general. 我知道我必须遗漏一些关于命令如何工作的非常基本的理解。 Also I am very new to linux, so may be thats the reason for not understanding this.
另外我对linux很新,所以可能是不理解这个的原因。
Javac is used for compiling your java code. Javac用于编译java代码。 If you notice the WordCount example, there are lot of import statements which require you to add the corresponding jars in the classpath.
如果您注意到WordCount示例,则有许多import语句需要您在类路径中添加相应的jar。
when you run hadoop com.sun.tools.javac.Main WordCount.java
, hadoop would have already loaded all these dependent jar for compiling your program. 当你运行
hadoop com.sun.tools.javac.Main WordCount.java
,hadoop已经加载了所有这些依赖的jar来编译你的程序。 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 您可以通过运行javac WordCount.java来测试它,如果您的类路径中没有这些必需的jar,编译器会抛出
cannot find symbol
错误
With the Hadoop, you can set the compiler that you want it to use for compiling your code. 使用Hadoop,您可以设置希望它用于编译代码的编译器。
com.sun.tools.javac.Main is the programmatic interface for the Java Programming Language com.sun.tools.javac.Main是Java编程语言的编程接口
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
执行
bin/hadoop
,第一个参数为com.sun.tools.javac.Main
,第二个参数为WordCount.java
,它使用com.sun.tools.javac.Main
编译WordCount.java
More on com.sun.tools.javac.Main
有关
com.sun.tools.javac.Main
更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.