3

I am so pain for installing scribe & hdfs. worth to appreciate, I solved most of the problems. However, I am stuck here.

I install libhdfs , and I write a "Hello world" test:

#include <iostream>
#include <string>
using namespace std;
#include "hdfs.h"

int main(int argc,char *argv[]){
    string host = "10.210.74.143";
    int port = 9000;
    hdfsFS fs = hdfsConnect(host.c_str(),port);
    return 0;
}

It print this msg when I run it:

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

I swear I have set the CLASSPATH

javanna
  • 59,145
  • 14
  • 144
  • 125
renenglish
  • 728
  • 1
  • 9
  • 18
  • usually when I have seen can't find java/lang/Object it means it cannot find the Java Runtime Environment (aka the JVM). – Chris Aldrich Dec 20 '11 at 21:47

1 Answers1

0

Firstly, you are running a C program instead of using a dynamic library from a Java Program. Is that really what you intended to do?

If so, maybe you need to explicitly create a JVM (interesting): See http://www.inonit.com/cygwin/jni/invocationApi/c.html unless hdfsConnect function does it for you.

Ustaman Sangat
  • 1,505
  • 1
  • 14
  • 26
  • hdfsConnect will create a JVM for me . I solve the problem , libhdfs get the jars in a certain path , not the CLASSPATH , I do not know the reason. – renenglish Dec 21 '11 at 04:47
  • I copied the code you gave in http://www.inonit.com/cygwin/jni/invocationApi/c.html then compile it : gcc -o hello hello.c -I /usr/java/jdk1.6.0_25/include/ -I/usr/java/jdk1.6.0_25/include/linux -L /usr/java/jdk1.6.0_25/jre/lib/amd64/server/ -ljvm but when I run ./hello , it prints : Error occurred during initialization of VM Unable to load native library: /usr/libjava.so: cannot open shared object file: No such file or directory – renenglish Dec 21 '11 at 08:22
  • @renenglish, so they look for jars in a certain path, huh? bummer. As for not finding libjava.so, I think the JAVA_HOME might not have been set up properly. On windows the library (java.dll) would be under JAVA_HOME\bin – Ustaman Sangat Dec 22 '11 at 20:32
  • Well the library java.dll (or libjava.lib) seems to be part of the JRE and not the JDK. Not sure if that matters though. – Ustaman Sangat Dec 22 '11 at 20:35
  • Now I solved the problem , I copied libjvm.so to /usr/lib64 , when I linked with it , then here is the problem : it can not find the libs it depends on. The correct method is linking with the libjvm.so in $JAVA_HOME( for me is :/usr/java/jdk1.6.0_25/jre/lib/amd64/server/libjvm.so) using -Wl,-rpath – renenglish Dec 27 '11 at 03:31