Java and R

From DISI
Revision as of 21:55, 30 June 2016 by Benrwong (talk | contribs) (Created page based on "R & JAVA" from Lab Manual)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Installation

There are two ways to install java, one way is from source (which is done on the cluster) or the other way is through yum. Yum is the easiest way to install it. For the version through yum it’s easy, just type R, etc. For using the one on the cluster, it’s much different. You must install and configure java differently. This is because the version on the cluster looks for a library that doesn’t exist on the default version (/usr/java/jdk1.7.0_67/include). Here are the steps for java:

Go to this site to download Java rpms:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Make sure you download both the jdk and the jre.

alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 20000
alternatives --config java  ---> To make sure it says that it’s the latest java
alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_67/bin/javac 20000
alternatives --install /usr/bin/javaws javaws /usr/java/jre1.7.0_67/bin/javaws 20000
alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 20000 

Then once you are done with that, add the following in the .cshrc file: ____________________

source /nfs/soft/python/envs/complete/python-2.7.7/env.csh
setenv JAVA_HOME '/usr/java/jdk1.7.0_67/jre'
setenv JAVA '/usr/bin/java'
setenv JAVAC '/usr/bin/javac'
setenv JAVAH '/usr/java/jdk1.7.0_67/bin/javah'
setenv JAR '/usr/java/jdk1.7.0_67/bin/jar'
setenv JAVA_LIBS '-L$(JAVA_HOME)/lib/amd64/server -ljvm'
setenv JAVA_CPPFLAGS '-I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux -I/usr/local/include'
setenv JAVA_LD_LIBRARY_PATH '$(JAVA_HOME)/lib/adm64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64:$(JAVA_HOME)/lib:/usr/lib'

alias R /nfs/soft/R/latest/bin/R

You can try to install packages like this:

R
install.packages(‘rJava’)
Debugging java stuff: type R CMD javareconf -e

Make sure that the java variables in the .cshrc match the paths that javareconf prints to the screen. For example, for Sarah I have the following in her .cshrc file:

setenv JAVA_HOME '/usr/java/jdk1.7.0_67/jre'
setenv JAVA '/usr/bin/java'
setenv JAVAC '/usr/bin/javac'
setenv JAVAH '/usr/java/jdk1.7.0_67/bin/javah'
setenv JAR '/usr/java/jdk1.7.0_67/bin/jar'
setenv JAVA_LIBS '-L$(JAVA_HOME)/lib/amd64/server -ljvm'
setenv JAVA_CPPFLAGS '-I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux -I/usr/local/include'
setenv JAVA_LD_LIBRARY_PATH '$(JAVA_HOME)/lib/adm64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64:$(JAVA_HOME)/lib:/usr/lib'

References for Java

References for Java: http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/