Till Baumgaertel
2003-Mar-03 02:25 UTC
[R] Q: Best-Practice for Swing-GUI calling R-code on Windows?
org.omegahat.R.Java.REvaluator e = new org.omegahat.R.Java.REvaluator(); Object val = e.eval("objects()"); if(val != null) { String[] objects = (String[])val; for(int i = 0 ; i < objects.length; i++) System.err.println("("+i+") " + objects[i]); } hello, thanks to Philippe Grosjean's work I finally got SJava working (on Windows XP!!), so that I can call Java-Code from within R. Now I wanted to write a little Swing-GUI for entering some values and executing a R-call with them. The results should also be presented in the Java-layer. If possible, I'd like to see the R-console because I cat() some text what I like (but not need) to see. Now I'm wondering what's best practice for that? Trying to call R from within Java I get an exception: java.lang.UnsatisfiedLinkError: eval at org.omegahat.R.Java.REvaluator.eval(Native Method) at org.omegahat.R.Java.REvaluator.eval(REvaluator.java:86) at org.omegahat.R.Java.REvaluator.eval(REvaluator.java:36) at SJavaTest.Main.main(Main.java:18) Exception in thread "main" My SJava.DLL is in the PATH as well as the SJava-BaseDir and the Jars in SJava/org/omegahat/Jars are in the classpath. any suggestions for solving that? Calling my GUI from within R is possible using .JNew and invoking show() on the new instance. I can see the interface, but again I got stuck because I cannot run R-code. the code I'd like to try first is the very first example from the "Calling R from Java"-Tutorial: ######### org.omegahat.R.Java.REvaluator e = new org.omegahat.R.Java.REvaluator(); Object val = e.eval("objects()"); if(val != null) { String[] objects = (String[])val; for(int i = 0 ; i < objects.length; i++) System.err.println("("+i+") " + objects[i]); } ########## could anybody give me a hint why this is not working or how i could solve my original problem the "best" way?? thanks for any hints, till
ripley@stats.ox.ac.uk
2003-Mar-03 08:55 UTC
[R] Q: Best-Practice for Swing-GUI calling R-code on Windows?
On Mon, 3 Mar 2003, Till Baumgaertel wrote:> org.omegahat.R.Java.REvaluator e = new > org.omegahat.R.Java.REvaluator(); > > Object val = e.eval("objects()"); > > if(val != null) { > String[] objects = (String[])val; > for(int i = 0 ; i < objects.length; i++) > System.err.println("("+i+") " + objects[i]); > } > hello, > > thanks to Philippe Grosjean's work I finally got SJava working (on Windows > XP!!), so that I can call Java-Code from within R.I don't think you have `got SJava working', as the error below is one symptom of incomplete fixing of SJava. (I am not sure what work of Philippe Grosjean you are referring to, but I had to rewrite parts of the Makefile.win as well as patch the R sources. I sent the changes to Duncan TL back in November.) There are patched sources and a compiled Windows binary version of SJava for 1.6.2 at http://www.stats.ox.ac.uk/pub/bdr/SJava. These were tested pretty extensively last week, and the sources even work under R-devel (1.7.0 to be). They are prepared for a project I am involved with, so there are no promises that they will stay available. (There is even a binary for R-devel in the bin/windows/contrib/rw1070 area of CRAN.)> Now I wanted to write a little Swing-GUI for entering some values and executing > a R-call with them. The results should also be presented in the Java-layer. > If possible, I'd like to see the R-console because I cat() some text what > I like (but not need) to see.Take a look at the installed examples in SJava (not all of which seem operational).> > Now I'm wondering what's best practice for that? > > Trying to call R from within Java I get an exception: > java.lang.UnsatisfiedLinkError: eval > at org.omegahat.R.Java.REvaluator.eval(Native Method) > at org.omegahat.R.Java.REvaluator.eval(REvaluator.java:86) > at org.omegahat.R.Java.REvaluator.eval(REvaluator.java:36) > at SJavaTest.Main.main(Main.java:18) > Exception in thread "main"[...] -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595