Problem running R script

Hi, I was trying to run that first example plugin you posted in a Windows 64 machine and I get the following error:

C:\Users\juanpps\AppData\Local\Temp\java6967928720114382182\src\main\java\Rserve_Example.java:29: cannot access java.lang.CharSequence
bad class file: C:\Fiji_app\java\win64\jdk1.8.0_66\jre\lib\rt.jar(java\lang\CharSequence.class)
bad constant pool tag: 18 at 10
Please remove or make sure it appears in the correct subdirectory of the classpath.
            c.eval("" + name + "<-matrix(runif(1000000)*2500,1000,1000)");
                             ^
1 error
15 warnings
org.scijava.minimaven.JavaCompiler$CompileError: Compile error: 1
    at org.scijava.minimaven.JavaCompiler.call(JavaCompiler.java:105)
    at org.scijava.minimaven.MavenProject.build(MavenProject.java:538)
    at org.scijava.minimaven.MavenProject.build(MavenProject.java:463)
    at org.scijava.minimaven.MavenProject.build(MavenProject.java:446)
    at org.scijava.plugins.scripting.java.JavaEngine.compile(JavaEngine.java:211)
    at org.scijava.plugins.scripting.java.JavaEngine.eval(JavaEngine.java:135)
    at org.scijava.plugins.scripting.java.JavaEngine.eval(JavaEngine.java:173)
    at org.scijava.script.ScriptModule.run(ScriptModule.java:173)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:167)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:126)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:65)
    at org.scijava.thread.DefaultThreadService$2.call(DefaultThreadService.java:191)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

do you know what the problem might be?

thank you

Do you have the required java R libs on the classpath? This example only runs if you have installed the required libs, installed and started the R package ‘Rserve’ inside of an R application. Then you can connect your Java plugin to R.

See the installation instructions here:

https://rforge.net/Rserve/

or StackOveflow might be easier:

1 Like

This looks like a Java skew issue. Can you please run Help > Report a Bug, then copy and paste the “Useful information about your system” box.

Also I suggest trying Renjin for R scripting in ImageJ.

Renjin does not work with the regular R packages (which are often built upon C++, Fortran sources) and even the plot devices do not work.

So I would’nt recommend it at the moment.

It is a work in progress if they can ever make it happen to support all available R packages.

If you try out some listed packages with Renjin many errors will be thrown.

So first of all, @Juanpps what is your end goal with R in ImageJ?

Second, if you do need additional packages, are they provided in the Renjin package list and if so can please you try using them in the ImageJ script editor?

Hi All. I am trying to send to R some pixel intensity signals extracted from videos and get back some values analized from those signals. I might also need to plot something in R so maybe Renji is not a good option.
I think I have all the files in the jars folder but I will check again. I wont have acces to my computer for a couple of days but then I will post again an update.
Thank you guys for the help.

When you’re using R scripting in ImageJ (which evaluates scripts in Renjin) you can mix R and ImageJ functions. So you do not necessarily have to use R to do plotting. ImageJ has a Plot API.

@Bio7 is definitely the expert at using RServe with ImageJ, which I expect will give you the most powerful result, but may require more knowledge of R and Java development.

If you want to explore Renjin scripting further and see if that’s sufficient for your needs I’m happy to help, just let me know e.g. what functions in R do you want to call exactly, what functions in ImageJ do you want to use, etc…

2 Likes

Hi All, I moved to another computer, this one is a windows 10 with java version 8. I tried again the script Rserve_Example.java and now it works perfectly!!!. I am still confused how it works despite of the java version because I did not fix anything regarding that.

Thanks for all your help.