Re: JGR with free java (was: GUI for R)
On Oct 20, 2006, at 11:13 AM, Egon Willighagen wrote:
cc: debian-java -> I need a bit of help here, see below
[...]
I've found out that it now actually is a package on CRAN, and
installs fine, and really just depends on rJava for the Java
binding. (JGR and rJava are downloaded as source tar.gz from [1]).
Thanks for the hints as of how to get it running with GIJ. I'm the
maintainer of rJava, so I do appreciate being CC'ed in such matters ;).
I had a brief go at installing rJava against GIJ:
$ JAVA_HOME=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0 R CMD
INSTALL --library=/usr/local/lib/R/site-library rJava_0.4-11.tar.gz
I was able to install it using the "regular" package installation:
sudo R
> install.packages("rJava")
Specifying JAVA_HOME should not be necessary as long as "java" is on
the PATH.
(R comes with the package r-base).
You need to have java-gcj-compat-dev and libgcj-bc installed.
But it fails because of this call:
/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/bin/javac -target 1.4 -source
1.4 -target 1.4 -source 1.4 -classpath src/JRI.jar -d examples
examples/rtest.java
Note the duplicate '-target 1.4 -source 1.4', which is OK for the
Sun javac,
but breaks compiling with gcj 4.1 javac.
Ok, thanks, I'll fix that for the next JRI/rJava release (in fact it
will be fixed in tonight's nightly build).
However, running it still fails with this error:
$ R
<snip>
and then on the R command line:
> library(rJava)
which fails with:
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared
library '/usr/local/lib/R/site-library/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error in library(rJava) : .First.lib failed for 'rJava'
Not sure what else I can/should try now. Ideas?
Your R is apparently configured without Java support. If you have R
2.4.0, run
sudo R CMD javareconf
and everything should be fine. If you have R 2.3.1 (earlier versions
won't work at all), then you have to edit
/usr/lib/R/etc/ldpaths
and replace the first line
: ${R_JAVA_LD_LIBRARY_PATH=}
with
: ${R_JAVA_LD_LIBRARY_PATH=/usr/lib/gcj-4.1:/usr/lib/jni}
This will make rJava work (at least it did on my Debian system). The
good news is that iplots appear to work nicely (that's a good test as
iplots are not quite trivial). The bad news is that JGR doesn't quite
work. Although I was able to start JGR with GIJ, its Swing
implementation seems to be incomplete/incompatible such that I get
tons of exceptions on the console that fail in the middle of the GIJ
Swing implementation code (somewhere in the event dispatch with a
failed assertion).
Therefore for JGR I can only recommend using Sun's Java (or IBM or
Blackdown ...) for now which is easy to install on Debian via make-
jpkg (obtainable via apt-get install java-package). If someone can
look into the Swing problems in GIJ, please do so, I'd be delighted
if we had a version running against free Java, but we don't have the
resources here to dig deep into that.
Thanks,
Simon
PS: For those not familiar with R that want to give it a shot, JGR
can be installed by typing in R (as root):
install.packages("JGR",dep=T)
and start JGR with
library(JGR)
JGR()
the latter will create a start shell script that can be used
consequently (it shows you where to find it).
PPS: It is not necessary to re-compile rJava even when switching Java
implementations (i.e. you can compile rJava against Sun's Java and
use it with GIJ or vice-versa), in R 2.4.0 you can simply change the
"java" on PATH or set different JAVA_HOME and run "R CMD javareconf"
- that's all.
Reply to: