[英]Could not load class when executed with -cp option of `'hadoop classpath`
my question is very close to this one, which is already answered. 我的问题与这一问题非常接近,已经得到解答。 Could not load class when executed with -cp option
使用-cp选项执行时无法加载类
However, the situation is slightly different 但是,情况略有不同
$ javac -cp `hadoop classpath` GrabHDFSBlockInfo.java
$ java -cp `hadoop classpath` GrabHDFSBlockInfo
Error: Could not find or load main class GrabHDFSBlockInfo
$ ls GrabHDFSBlockInfo*
GrabHDFSBlockInfo.class GrabHDFSBlockInfo.java
so I'd like to use the shortcut of hadoop classpath
in this case. 所以在这种情况下,我想使用
hadoop classpath
的快捷方式。
many thanks for your help 非常感谢您的帮助
Demai 德迈
edit: thanks for everyone's help. 编辑:谢谢大家的帮助。 Since hadoop classpath doesn't change much on my cluster.
由于hadoop classpath在我的集群上变化不大。 I eventually change my .bashrc, by setup a var with expanded classpath padding ':.'
我最终通过设置带有扩展类路径填充':'的var来更改.bashrc。 then, just use $ java -cp $classpath GrabHDFSBlockInfo
然后,只需使用$ java -cp $ classpath GrabHDFSBlockInfo
One of the known problems of hadoop classpath
is that it contains wildcards. hadoop classpath
的已知问题之一是它包含通配符。 As a result of that, the hadoop libraries cannot be loaded properly. 结果,hadoop库无法正确加载。 As a workaround, try expanding the wildcards, replacing them with sequences of jars located there.
解决方法是,尝试扩展通配符,将其替换为位于此处的jar序列。 It will most probably help.
这很可能会有所帮助。
A little zsh script for a similar purpose (though I simply updated existing CLASSPATH there): 出于类似目的的一些zsh脚本(尽管我只是在那里更新了现有的CLASSPATH):
classpath=`hadoop classpath | tr ':' ' ' | sort | uniq`
for file in ${=~classpath}(N)
do
export CLASSPATH=$CLASSPATH:$file
done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.