The scenario:
- Processing.R mode is installed in PDE.
- The R mode includes a resource ( renjin-script-engine.jar / renjin-script-engine-0.8.2413-jar-with-dependencies.jar)
- This could be used to run R in a Java mode sketch.
I want to write an example sketch in Java mode demonstrating how to import resources from Processing.R mode and use them to integrate an R process into a Java mode sketch. The Java sketch would include a line like this:
import org.renjin.sexp.*
However this does not work because the jars of Processing.R mode are not in the Java mode path.
Is there a workaround?
Partial solutions I can think of:
- include renjin-script-engine.jar again in the RinJava.pde example sketch path. However this needs to be copied to every new sketch -- and the user already had this jar installed in their system in the Processing.R mode!
- write a separate library for PDE Contributions Manager called "RinJava" that includes renjin-script-engine.jar, and have users install the library and import it to a Java sketch. This is better, but it still requires two installs of the same jar, and it doesn't allow the Java crossover example to be distributed directly with the R mode.
- use dark magic to place renjin-script-engine.jar directly in the existing Java mode, perhaps during Processing.R install. This seems like a bad idea, because (among other potential problems) any update to Processing(Java mode) could remove the change.
Ideally there would be a way to access Processing.R mode jars from a Java mode sketch -- then if the R mode is installed, a Java sketch could also use it.
Any suggestions?
Answers
In case you are curious, here is the example Java sketch that would be importing from Processing.R -- but the details of the sketch don't matter, only getting the import statement to work.
So far it looks like the answer is "this just isn't possible" ...
...unless Processing's core Java mode enabled it as a feature. That doesn't seem to make a lot of sense: it would create a lot of headaches and complexity for an extremely narrow use case.
It looks like the best solution would be a separate Processing(Java) library e.g. "RInJava" to compliment the Processing.R mode.
Drawbacks: because that library would use a separate duplicate jar from the mode, they would take up twice the space, and the library and the mode could get out of sync on the features supported. But otherwise a library should work.