Renjin with eclipse (not maven)

43 views
Skip to first unread message

thesprinti...@gmail.com

unread,
Jul 3, 2020, 8:37:19 AM7/3/20
to Renjin
Hi!

Apologies if this has been covered elsewhere but I have searched the group and couldn't find anything. I am developing a project that requires part of my computation to be in R and another part in java. I downloaded all of the renjin jars and added them to my module path, and am trying to run a very simple example script but I have reached an error I cannot get past: 

Exception in thread "main" java.lang.NoClassDefFoundError: org/renjin/gcc/runtime/FunPtrDdIIII

I have never used Maven so am reluctant to start now, and do not have admin privileges on my laptop so cannot install anything at all. Can you help me get started? I was looking for a jar with dependencies but couldn't find one so instead I downloaded and linked all of the separate jars in my build path. I can confirm gcc-runtime-0.7.1515.jar is in my class path and module path. 

Best wishes,

Steph 

Alexander Bertram

unread,
Jul 3, 2020, 8:44:31 AM7/3/20
to Renjin
Dear Steph,

The class that's missing (org/renjin/gcc/runtime/FunPtrDdIIII) is actually one that should have been generated on the fly by the build system when compiling R packages that have C code and use function pointers. This is a strategy we used long ago, before MethodHandle support came with Java 7. 

The generated function pointer wrappers were included with the compiled package jar, so i suspect you have some sort of version conflict. Can you double check that all of the jars from Renjin are from the same release?

Also, we do our best to ensure that new versions of Renjin continue to work with packages compiled with older versions of Renjin, but it's possible that is leading to a problem. If there's a specific version of package you need, you can find which version of Renjin was used to build it from packages.renjin.org, and try to use the same version of Renjin and see if the problem goes away.

If that doesn't work, try to post your full classpath to gist.github.com and share the link here, I can take another look.

Best,
Alex

thesprinti...@gmail.com

unread,
Jul 6, 2020, 10:58:44 AM7/6/20
to Renjin
Dear Alexander,

Thank you for your fast response! 

I was able to get past my initial error by moving everything from the module path to the class path except , but now the error is:

Exception in thread "main" java.lang.RuntimeException: java.nio.file.InvalidPathException: Illegal char <<> at index 22: org\renjin\grDevices\[<-.raster.RData



Thanks again,

Steph 

Bertram, Alexander

unread,
Jul 7, 2020, 4:10:20 AM7/7/20
to renji...@googlegroups.com
Hmm, not sure about this. 

Many of the R functions indeed use symbols like "<-" and I haven't encountered a problem loading them before. I know some file systems like WIndows FAT32 can be more difficult about path names, but generally these resources are loaded from the JAR (.zip) files rather than from a file. You're not unpacking the jars are you?




--
You received this message because you are subscribed to the Google Groups "Renjin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to renjin-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/renjin-dev/9270166f-533b-4c72-a8b7-cd9fb0243c08o%40googlegroups.com.


--
Alexander Bertram
Technical Director
BeDataDriven BV

Web: http://bedatadriven.com
Email: al...@bedatadriven.com
Tel. Nederlands: +31(0)647205388
Skype: akbertram

thesprinti...@gmail.com

unread,
Jul 7, 2020, 6:05:16 AM7/7/20
to Renjin
It's worth adding that I am using what I think is an old version of renjin but I can't find the 3.5 jar anywhere!!!!

Steph

thesprinti...@gmail.com

unread,
Jul 7, 2020, 6:05:20 AM7/7/20
to Renjin
I was unpacking the jars yes! I changed to importing the zip file (renjin-3.5-beta76.zip) and the module-info file can access renjin just fine but it doesn't seem to be able to find the packages (e.g. org.renjin.script) is this because I don't have the jar with dependencies? 

Sorry that I am finding this so difficult you have been beyond helpful! 

Best wishes,

Steph
To unsubscribe from this group and stop receiving emails from it, send an email to renji...@googlegroups.com.

Bertram, Alexander

unread,
Jul 7, 2020, 8:22:08 AM7/7/20
to renji...@googlegroups.com
Looks like you're using Java 9? 

I know others had an issue crafting the right module-info.java: 

I'm afraid that we just haven't made the move yet to java 9, so i'm not yet knowledgeable enough to give you a 100% confident answer. I suspect it has something to do with reflection. See the follow result of uncritical googling:

Anyone else using Renjin with Java 9?

Best,
Alex


To unsubscribe from this group and stop receiving emails from it, send an email to renjin-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/renjin-dev/93ac08ef-2386-45c8-a101-5a3ecd235622o%40googlegroups.com.

Per Nyfelt

unread,
Jul 7, 2020, 1:50:58 PM7/7/20
to Renjin
@Alex: I have not tried java 9 but it works fine in java 11.

@Steph: If you just want to run the script engine, you can make the list of jars much shorter: i.e.

./gcc-bridge-runtime-3.5-beta76.jar
./renjin-nmath-3.5-beta76.jar
./maven-scm-provider-svnexe-1.4.jar
./maven-scm-api-1.4.jar
./renjin-blas-3.5-beta76.jar
./slf4j-api-1.6.1.jar
./maven-scm-provider-svn-commons-1.4.jar
./tools-3.5-beta76.jar
./codemodel-2.6.jar
./xz-1.8.jar
./commons-logging-1.1.1.jar
./commons-compress-1.18.jar
./slf4j-jdk14-1.6.1.jar
./renjin-core-3.5-beta76.jar
./renjin-asm-5.0.4b.jar
./renjin-guava-28.0b.jar
./jfreesvg-3.3.jar
./plexus-utils-1.5.6.jar
./datasets-3.5-beta76.jar
./renjin-script-engine-3.5-beta76.jar
./renjin-lapack-3.5-beta76.jar
./commons-vfs2-2.0.jar
./grDevices-3.5-beta76.jar
./stats-3.5-beta76.jar
./renjin-common-3.5-beta76.jar
./utils-3.5-beta76.jar
./renjin-appl-3.5-beta76.jar
./regexp-1.3.jar
./renjin-gnur-runtime-3.5-beta76.jar
./core-1.1.2.jar
./graphics-3.5-beta76.jar
./methods-3.5-beta76.jar
./commons-math-2.2.jar


With those dependencies, a simple test like this:

package se.alipsa;


import org.renjin.script.RenjinScriptEngine;
import org.renjin.script.RenjinScriptEngineFactory;
import org.renjin.sexp.SEXP;


import javax.script.ScriptException;


public class SimpleTest {


   
public static void main(String[] args) throws ScriptException {
     
RenjinScriptEngineFactory renjinScriptEngineFactory = new RenjinScriptEngineFactory();
     
RenjinScriptEngine engine = renjinScriptEngineFactory.getScriptEngine();


      SEXP result
= (SEXP)engine.eval("p <- 48; foo <- function(a, b) { return( a * b) }; bar <- foo(p, 2)");
     
System.out.println("Result is " + result.asInt());
   
}
}

using a primitive build script like this

#!/usr/bin/env bash


basedir
="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"


srcDir
="${basedir}/src"
outDir
="${basedir}/out"
libDir
="${basedir}/lib"


java
-version
javac
-version


echo
"Compiling..."
javac
-g -cp "${libDir}/*" -d "${outDir}" -Xlint:unchecked $(find "${srcDir}"/* | grep .java)


echo "Running SimpleTest"
java -cp "${libDir}/*:${outDir}" se.alipsa.SimpleTest

yields the following output:

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)
javac 11.0.7
Compiling...
Running SimpleTest
Result is 96

Regards,
Per
Reply all
Reply to author
Forward
0 new messages