HenrikBengtsson / CBI-software

A Scientific Software Stack for HPC (CentOS oriented)
https://wynton.ucsf.edu/hpc/software/software-repositories.html
5 stars 2 forks source link

R: Assert 'java' and 'javac' are of same version #72

Closed HenrikBengtsson closed 2 years ago

HenrikBengtsson commented 2 years ago

If java and javac are of different versions, then {rJava} fail to install.

Notes:

$ java -version
openjdk version "1.8.0_312"
$ javac -version
javac 11.0.15

These should be the same. The fix is:

$ sudo update-alternatives --config java # pick "auto"
$ sudo update-alternatives --config javac # pick "auto"
$ R CMD javareconf
HenrikBengtsson commented 2 years ago
$ java -version 2>&1 | head -1 | sed -E 's/.*"(.*)".*/\1/'
11.0.15
 javac -version | head -1 | sed 's/.* //'
11.0.15

=>

JAVA_VERSION=$(java -version 2>&1 | head -1 | sed -E 's/.*"(.*)".*/\1/')
JAVAC_VERSION=$(javac -version | head -1 | sed 's/.* //')

JAVA_VERSION_XY=$(echo "$JAVA_VERSION" | sed 's/[.][^.]*$//')
JAVAC_VERSION_XY=$(echo "$JAVAC_VERSION" | sed 's/[.][^.]*$//')