I have continued this on the stats-rosuda-devel mailing list. Saptarshi Guha
On Sun, Apr 5, 2009 at 10:12 AM, Simon Urbanek <simon.urba...@r-project.org>wrote: > > On Apr 5, 2009, at 9:26 AM, Saptarshi Guha wrote: > > Not sure if this the right place, but I can't seem to subscribe to the >> rJava >> mailing list. Sorry for the noise. >> >> > The correct mailing list is stats-rosuda-devel: > http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel > > (The rJava mailing list was a test but it turned out that everyone is still > using stats-rosuda-devel so the idea of a separate list was abandoned). > > > 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. >> >> > Can you, please, send me the exact code you're using? (I.e. exactly the > value of CLASSPATH, your platform, how you started R and initialized rJava > and what you tried to do to load the class). > > A side note - preferably you should not be using the CLASSPATH environment > variable, because that is very limited and doesn't work if you have multiple > packages using Java. Instead use .jinit or .jpackage (under the hood > CLASSPATH gets converted but that is for compatibility only). > > > 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? >> >> > No, more likely that your code is using the wrong class loader for loading > files. The code below sets the path in the system class loader but that is > not the loader used by R code. Since R needs to modify the class path on the > fly (as packages are loaded) it uses its own class loader. It seems as if > you are bypassing that loader and thus running into problems (without exact > details we can't tell for sure). > > Cheers, > Simon > > > > ==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]] >> >> ______________________________________________ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> >> > [[alternative HTML version deleted]] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel