Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting R to use newer versions of java

Tags:

java

r

netlogo

This question is related to this other question.

I am trying to use RNetLogo with R and get the following error.

nl.path <- "/Applications/NetLogo 5.1.0"
NLStart(nl.path) 
Error in .jnew("nlcon/Preprocess") : 
  java.lang.UnsupportedClassVersionError: nlcon/Preprocess : Unsupported major.minor version 51.0

From what I understood in this other question, the problem is that R is using an old version of Java which is incompatible with RNetLogo.

I installed Java 8.0 hoping to solve the problem but my understanding is that, despite Java 8.0 being installed on my computer (Mac OS Maverick), R does not pick it up and keep trying to use old versions of Java.

So my question is : How can I get R to use Java 8.0 instead of any older version?

In the terminal console, I get

java -version :
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Thanks in advance for your help,

like image 996
Martin Van der Linden Avatar asked Nov 04 '14 21:11

Martin Van der Linden


People also ask

How do I check my Java version in R?

Click Start. Type %windir%\SysWoW64\cmd.exe in Start Search box. Press Enter. Type java -version.

What is the latest version of Java in 2021?

Java 18 General Availability began on March 22, 2022, and for Java 17, the latest (3rd) LTS on September 14, 2021.

What is the most recent JDK?

As of March 2022, Java 18 is the latest released Java version. In September 2022, Java 19 will follow. The last long-term support version (LTS) of Java is Java 17, released in September 2021.

Do you need Java for rJava?

Prerequisites. The rJava package requires the following. A bit-matching 32-bit or 64-bit version of the Java Runtime Environment (JRE), version 6 or later is installed. The system variable JAVA_HOME is set.


1 Answers

Seems like on Mac OS X you can have multiple Java at a one time.

Use below command on terminal to check how many JDK version you have.

/usr/libexec/java_home -V

You can follow below instruction to have correct Java Path setup:

How To Set $JAVA_HOME Environment Variable On Mac OS X

In nutshell do:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

like image 93
pinakin Avatar answered Sep 21 '22 02:09

pinakin