简体   繁体   English

用于MapR / Hadoop / Hive的类路径

[英]Classpath to use for MapR/Hadoop/Hive

I'm trying to compile some java code for hadoop and need to know what classpath I need to specify. 我正在尝试为hadoop编译一些Java代码,并且需要知道我需要指定什么类路径。 For cloudera I use this below but what do I use for a MapR installation? 对于cloudera,我在下面使用此功能,但如何安装MapR? Surprisingly I could only find how to set the classpath in google, not what to set it to. 令人惊讶的是,我只能找到如何在Google中设置类路径,而不是将其设置为什么。

javac -classpath "/opt/cloudera/parcels/CDH-4.6.0-1.cdh4.6.0.p0.26/lib/hadoop/client/*" mr.java -d mr

Found the answer by trial and error. 通过反复试验找到了答案。 Oddly google is very silent on this and all the books and examples I've read appear to assume this is too obvious to bother printing. 奇怪的是,谷歌对此非常沉默,我读过的所有书籍和示例似乎都认为这太明显了,无法打扰打印。

mkdir MyClass
javac -classpath "/opt/mapr/hadoop/hadoop-0.20.2/lib/*" MyClass.java -d MyClass
jar -cvf MyClass.jar -C MyClass .

Additionally, if you want the hive libraries, eg for compiling a hive UDF: 另外,如果您想要配置单元库,例如用于编译配置单元UDF:

javac -classpath "/opt/mapr/hadoop/hadoop-0.20.2/lib/*:/opt/mapr/hive/hive-0.12/lib/*" MyClass.java -d MyClass

EDIT: one thing I would add is make sure you put quotes around the path, otherwise linux expands it on the command line which is not what you want. 编辑:我要添加的一件事是确保您在路径两边加上引号,否则linux在命令行上扩展它,而不是您想要的。 The * in the path needs to be passed to java as is. 路径中的*需要按原样传递给java。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM