0

I am trying to load the JRI in my webstart-application. I always get this exception:

Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path. 

JNLP file:

...
<resources>
    ...
    <jar href="JRI.jar" />
    ...

    <nativelib href="JRI.jar" />

</resources>
...

I use a batch script to run my application under Windows 7:

set R_HOME=C:\ProgramData\R\R-2.14.0
set R_PATH=C:\ProgramData\R\R-2.14.0\library\rJava\jri
set JNLP_URL=http://localhost/app/app.jnlp
set WEBSTART="C:\Program Files\Java\jre7\bin\javaws.exe"

SET PATH=%PATH%;%R_HOME%\bin\i386;%R_PATH%

%WEBSTART% %JNLP_URL%

I try to use an sh script to start my application under Linux (Ubuntu):

#!/bin/bash

export R_HOME=/usr/lib/R/
export r_home=/usr/lib/R/
export rHome=/usr/lib/R/
export rhome=/usr/lib/R/
export rHOME=/usr/lib/R/

export R_PATH=/usr/lib/R/site-library/rJava/jri/
export r_path=/usr/lib/R/site-library/rJava/jri/
export rPath=/usr/lib/R/site-library/rJava/jri/
export rPATH=/usr/lib/R/site-library/rJava/jri/
export rpath=/usr/lib/R/site-library/rJava/jri/

export WEBSTART=/usr/lib/jvm/java-7-oracle/jre/bin/javaws

export JNLP_URL=http://localhost/app/app.jnlp

export PATH=$PATH:$R_HOME/bin:$R_PATH

$WEBSTART $JNLP_URL

For some reason it does work under Windows, but not under Linux. The two batch scripts should do the same...

The application works fine under both, Windows and Linux, until I try to use a method which tries to use R.

It also works completely (including R), when I start my application with the following sh script as a non-webstart version:

#!/bin/bash
export R_HOME=/usr/lib/R/
export rPATH=/usr/lib/R/site-library/rJava/jri/
export JAVA=/usr/lib/jvm/java-7-oracle/jre/bin/java
LIB=<<Libraries>> # I left out this very long line for this post :)
$JAVA -classpath $LIB:. -Djava.library.path=./FAST:$rPATH de.app.MainWindow $*

I have no clue why it is not working with webstart and Linux...

A jar -tvf JRI.jar gives me:

     0 Sun Oct 07 12:28:14 CEST 2012 META-INF/
    68 Sun Oct 07 12:28:14 CEST 2012 META-INF/MANIFEST.MF
     0 Sun Oct 07 12:28:12 CEST 2012 org/
     0 Sun Oct 07 12:28:12 CEST 2012 org/rosuda/
     0 Sun Oct 07 12:28:12 CEST 2012 org/rosuda/JRI/
  1079 Sun Oct 07 12:28:14 CEST 2012 org/rosuda/JRI/RVector.class
   582 Sun Oct 07 12:28:14 CEST 2012 org/rosuda/JRI/RMainLoopCallbacks.class
  2158 Sun Oct 07 12:28:14 CEST 2012 org/rosuda/JRI/RList.class
  1723 Sun Oct 07 12:28:14 CEST 2012 org/rosuda/JRI/RFactor.class
 10424 Sun Oct 07 12:28:14 CEST 2012 org/rosuda/JRI/Rengine.class
   734 Sun Oct 07 12:28:14 CEST 2012 org/rosuda/JRI/RBool.class
  1010 Sun Oct 07 12:28:14 CEST 2012 org/rosuda/JRI/RConsoleOutputStream.class
  3082 Sun Oct 07 12:28:14 CEST 2012 org/rosuda/JRI/Mutex.class
  9887 Sun Oct 07 12:28:14 CEST 2012 org/rosuda/JRI/REXP.class
190345 Sun Oct 07 12:28:12 CEST 2012 libjri.so

JaNeLA gives me

XML encoding not known, but declared as utf-8
'short' description is longer than 'default' description.

and for every resource jar I specified I got (example for persistence-api-1.0.jar):

Downloads can be optimized by specifying a resource size for 'persistence-api-1.0.jar'.
The resource download at persistence-api-1.0.jar can be optimized by removing the (default) value of download='eager'.
The resource download at persistence-api-1.0.jar can be optimized by removing the (default) value of main='false'.
It might be possible to optimize the start-up of the app. by  specifying download='lazy' for the persistence-api-1.0.jar resource.
Lazy downloads might not work as expected for persistence-api-1.0.jar unless the download 'part' is specified. 

All those notices are green or yellow.

Anon
  • 44
  • 4
  • ` ... ` It is one or the other, not both. A `jar` has classes, while a `nativelib` has natives. Be sure to check the JNLP using [JaNeLA](http://pscode.org/janela/). It would not pick up that particular error, but will detect *many* others. – Andrew Thompson Oct 04 '13 at 16:57
  • @Andrew Thombson I tried removing one of them. When I remove `` it does not crash with an exception but the responsible thread in my application, which is for executing the r part is just idling. There is no exception in my log files as well. When I remove `` I get the same error like when I use both commands. First I had this "idling-problem" under Windows, too. But then I just put both of those commands in the JNLP and it worked (but I'm not 100% sure, that this was the reason for it finally working under Windows). – Anon Oct 04 '13 at 17:23
  • It sounds like you are 'coding by magic'. By which I mean 'trying random things without understanding them'. You *need* to understand how this works, what will work, and what won't. So clear this up for me.. What exactly is in `JRI.jar`. And by 'exactly' I mean, do a `jar -tvf JRI.jar` and copy/paste the output as an [edit to the question](http://stackoverflow.com/posts/19186523/edit). Also give an intelligent response to my suggestion to use JaNeLA. I feel like I'm talking to myself here. What did it report? Did you fix all *the errors* that it identified? .. – Andrew Thompson Oct 04 '13 at 17:41
  • I'm sorry for not responding to the JaNeLA suggestion, that was a misunderstanding. I ran JaNeLA and did a `jar -tvf JRI.jar` and posted the results as an edit to my question. – Anon Oct 04 '13 at 18:44
  • Re. the output.. `..org/rosuda/JRI/REXP.class 190345 Sun Oct 07 12:28:12 CEST 2012 libjri.so` Yep, that's exactly what I advised you *not* to do in the first comment.. If you don't understand something I write, ask, and be specific about what you don't understand. The JaNeLA output indicates there are no *errors* in the current JNLP (you can ignore the warnings and optimizations). That is good, but it will still need to be changed before we are done. More on that after we sort these basics. – Andrew Thompson Oct 04 '13 at 18:47
  • I don't understand two things of your last comment: 1. What is it about '..org/rosuda/JRI/REXP.class 190345 Sun Oct 07 12:28:12 CEST 2012 libjri.so'? 2. What did you advise me not to do in your first comment? I thought you were telling me not to use both, the jar and the nativelib tags. – Anon Oct 04 '13 at 19:01
  • The advice was *"A `jar` has classes, while a `nativelib` has natives."* In other words, you need (at least) one Jar for classes, and (at least) one Jar for natives. **Don't** mix them in the same Jar! That output indicates a Linux/Unix native is in the same Jar as classes. It won't work that way. -- Another interesting bit about the output, is that it makes no mention of `.dll` yet you claim it is working on Windows. For that to work, either the `.dll` is in another Jar you've yet to mention, or more likely, it is 'installed' into the Windows system already. – Andrew Thompson Oct 04 '13 at 19:07
  • The JRI.jar comes with the download of the package "rJava" for R and is located at the install location of R on the system. I did the `jar -tvf` on my Linux system. I think if I would do it on Windows, there would be the .dll in it. I wanted webstart to use the **local** JRI.jar file. Is that even possible or is that my mistake? – Anon Oct 04 '13 at 19:20

0 Answers0