Not sure if this the right place, but I can't seem to subscribe to the rJava
mailing list. Sorry for the noise.

I have a jar file in the CLASSPATH variable. On running .jinit and checking
.jclassPath, i can see the jar file containing the class. Yet when trying to
instantaite the class, i get a class not found error.

Now If if, create my own vm (see below), and then run .jinit (which will use
my vm), i can find the class in question (org.apache.hadoop.io.longwritable)

Is there some classloader problem in rJava?

==code==
void create_vm(const char *clap) {
  char* classpath = (char*) calloc(18+strlen(clap)+1, sizeof(char));
  sprintf(classpath,"-Djava.class.path=%s",clap);
  JavaVMInitArgs args;
  JavaVMOption options[2];
  args.version = JNI_VERSION_1_4;
  args.nOptions = 2;
  options[0].optionString = classpath;
  options[1].optionString = "-Xrs";
  args.options = options;
  args.ignoreUnrecognized = JNI_TRUE;
  JavaVM *jvms[32];
  jsize vms=0;
  int r=0;
  r=JNI_GetCreatedJavaVMs(jvms, 32, &vms);
  if (r) {
    error("JNI_GetCreatedJavaVMs returned %d\n", r);
  } else {
    if (vms>0) {
      int i=0;
      while (i<vms) {
    if (jvms[i]) {
      if (!(*jvms[i])->AttachCurrentThread(jvms[i], (void**)&jenv, NULL)) {
        jvm=jvms[i];
        break;
      }
    }
    i++;
      }
      if (i==vms) error("Failed to attach to any existing JVM.");
    }else {
        JNI_CreateJavaVM(&jvm, (void **)&jenv, &args);
      }
    }
  }


Saptarshi Guha

	[[alternative HTML version deleted]]

