Setting up the software
Before setting up the software as described on this page, you'll need to get it. After setting it up, you should be able to run it.
Setting up R
The Java program uses R components. You must ensure you have a working installation of R before it will run.
Setting up R (Linux)
The R base package needs the fortran library, which I installed from the internet, but it might be on your Linux CD/DVD.
- su
- Find the Fortran library (eg, libgfortran.so.1.rpm) and install it
Now you can install the R base package:
- Follow the instructions from www.sourcekeg.co.uk/cran/bin/linux/suse/ReadMe.html, which was linked from one of the R project pages
- If you're using openSUSE, follow the link to http://software.opensuse.org/download/home:/dsteuer/ then find 10.2 and install R-base from the RPM file, just as for the fortran library above
Setting up R (Windows XP)
This is really easy: go to www.r-project.org.
There is nothing special you need to do after installing R 2.4.1 in the normal way.
Note that the current release is 2.5.0. You can get 2.4.1 by following the link to previous releases.
Setting up Java/R Interface (JRI)
The Java program uses the JRI from www.rosuda.org. You need to set this up properly before the program will compile or run.
Setting up JRI (Linux)
First you need to install the JRI software, which includes building it. Luckily, everything is done through the R CRAN.
- su
- Ensure that environment variable JAVA_HOME is pointing to the right place. Either export it from the shell or put in ~/.bashrc. The setting on my PC is:
- export JAVA_HOME=/usr/java/default
- After installing R, do
- R
- install.packages(„rJava“)
On my machine the installation put files in /usr/lib/R/library/rJava/jri (together with examples).
In order for Netbeans to be able to compile a program that uses JRI, you need to add a library. Here's how:
- In NetBeans, open the Library Manager and add a new library called JRI
- Set the classpath to wherever JRI.jar is. On my PC this is /usr/lib/R/library/rJava/jri/JRI.jar.
To use the library in a project you need to add it (JRI) to the project's properties. This should be done for you in the WrapR and ICAModel projects, but you'll have to do it yourself if you're going off-piste. It's very easy: just right-click on the project name in the tree, select properties, then add Library in the Compile tab of the dialog.
Finally, you need to ensure that Java can find the native libraries for R and JRI. If you don't do this then the program will compile but not run.
- Add the following line (or something similar) in n ~/.bashrc
- export LD_LIBRARY_PATH=/usr/lib/R/library/rJava/jri:/usr/lib/R/lib
- Log out and in again for it to take effect.
Setting up JRI (Windows XP)
You have the choice of building from scratch or attempting to use pre-built libraries that the development team will try to keep up to date.
Building from scratch
If you get stuck, you could look at http://cran.r-project.org/doc/manuals/R-admin.html#The-Windows-toolset
Note that you don’t need to build R from source but you DO need the Windows Toolset.
PATH=c:\Rtools\bin;c:\perl\bin;c:\Rtools\MinGW\bin;c:\html\help;c:\Rbin;c:\texmf\miktex\bin;...others...
Note that in the path you must:
- have no spaces in path names
- put c:\Rtools\bin 1st or 2nd in the list
Here's how to set the path, in case you're not familiar with this:
- Right-click on My Computer
- Choose Properties then the Advanced tab then Environment Variables
- Select Path and click Edit
In Windows you can't download and install rJava from the CRAN like in Linux above. You have to get it from the source code repository instead and compile it yourself. Here's how:
- Download rJava from http://www.rforge.net/rJava/ (I downloaded 0.4-16)
- You need some way of unzipping .tar files. I downloaded PowerArchiver 6.1 from http://www.sfsu.edu/ftp/win/utils/ and it did the job nicely.
- Unzipped the rJava tar into ProjectsJRIBuildrJava.
- From a command shell (start ; run... ; cmd):
- Change to the directory where you unzipped the JRI files as part of rJava (in my case Projects\JRIBuild\rJava\JRI)
- sh configure.win (this sets up the compiler)
- make (this runs the compiler to create jri.dll and some other files in the src subdirectory)
- To check it worked:
- Run rtest
- This runs a whole bunch of R then gives you a console.
- Type quit() to get out.
Setting up from built libraries
First you need to get your library files in the right place.
- If not built from scratch then get hold of JRI.jar and JRI.dll by checking out WrapR from the icamodel sourceforge repository. You should find them in the WrapR\src\RuntimeWinXP area. Hopefully these are compatible with your setup and don't cause any version conflicts, but if they do then you'll have to build from scratch as described above.
- You might like to create a folder c:\JRIlib and copy JRI.jar and jri.dll into it so that the paths are a bit shorter. Or you can just leave them where they are.
In order for Netbeans to be able to compile a program that uses JRI, you need to add a library. Here's how:
- In NetBeans, open the Library Manager and add a new library called JRI
- Set the classpath to wherever JRI.jar is. On my PC this is c:\JRIlib\JRI.jar.
To use the library in a project you need to add it (JRI) to the project's properties. This should be done for you in the WrapR and ICAModel projects, but you'll have to do it yourself if you're going off-piste. It's very easy: just right-click on the project name in the tree, select properties, then add Library in the Compile tab of the dialog.
Finally, you need to ensure that Java can find the native libraries for R and JRI. If you don't do this then the program will compile but not run. Here's how:
- Find the location of R.dll. Normally something like C:\Program Files\R\R-2.4.1\bin
- Find the location of JRI.dll (c:\JRIlib if you created it, otherwise wherever you downloaded or built the dll)
- Right-click on My Computer
- Choose Properties then the Advanced tab then Environment Variables
- Select Path and click Edit
- Add a semicolon to the end of the existing path, then the name of the folder containing R.dll, then another semicolon, then the name of the JRI.dll folder
Setting up the Java graphics device for R (JavaGD)
The software uses the R package JavaGD from www.rosuda.org to display R graphical output in Java. You need to set this up properly before the program will compile or run.
Setting up JavaGD (Linux)
...to follow shortly...
Setting up JavaGD (Windows)
In R, install the package JavaGD using the normal R installer. It should just set up automatically with no problems.
In order for Netbeans to be able to compile a program that uses JavaGD, you need to add a library. Here's how:
- In NetBeans, open the Library Manager and add a new library called JavaGD
- Set the classpath to wherever javaGD.jar is. On my PC this is C:\Program Files\R\R-2.4.1\library\JavaGD\java.
To use the library in a project you need to add it (JavaGD) to the project's properties, but this should be done for you in the WrapR and ICAModel projects.
Comments (0)
You don't have permission to comment on this page.