本文介绍了在C ++(libhdfs)中编写hdfs中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用C ++编写一个接口,使用libhdfs.so在hdfs中编写文件。我的目标hadoop版本是2.0.2-alpha

I am trying to write an interface in C++ to write files in hdfs using libhdfs.so. My target hadoop version is 2.0.2-alpha

以下代码

 hdfsFS fs = hdfsConnect("127.0.0.1",8020);
 if (!fs)
 {
    printf("Hadoop file system returned null. \n");
    return 0;
 }

在运行时提供以下错误:

provides the following error while running:

Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

相应地更新了CLASSPATH,但仍然收到此错误。
任何想法是什么是我在这里丢失的步骤?

Updated the CLASSPATH accordingly but still getting this error. Any idea what is the step I am missing here? All the .so files are linked correctly.

推荐答案

您可以使用以下命令查找hadoop所需的java类路径

You can use following command to find the java classpath needed by hadoop

路径环境变量CLASSPATH

And add all of these paths to environment variable CLASSPATH

是CDH4的libhdfs示例。请注意exec.sh

Here is a example of libhdfs for CDH4. Notice the environment settings in exec.sh

这篇关于在C ++(libhdfs)中编写hdfs中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 21:54