In this post we will concentrate on how to install and run R from regular Java process; in next post we will plug R into Hadoop mapreduce.
R is programming language and software environment written in C and FORTRAN, so interaction with Java requires JNI layer. It is provided by Java/R Interface project  and contains platform-specific .so files.
To prepare environment, we need both R and JRI installed and configured. For Ubuntu these are next two lines:
sudo apt-get install r-base r-recommended r-base-dev
sudo apt-get install r-cran-rjava
For other platforms follow steps from  to install R and  for JRI.
To reference .so files for Java processes, we need to update LD_LIBRARY_PATH and pass -Djava.library.path to JVM. Feel free to dig a little deeper on configuration reasoning in  and .
run.sh script in Ubuntu will look like:
Having environment configured, we can now turn to code:
 Java/R Interface
 Talking R through Java
 java.library.path and LD_LIBRARY_PATH
 How to convert a data frame column to numeric type?
 CRAN mirrors: chose your favourite location and follow R installation instruction:
 rJava package on CRAN