3

I just tried this, but I got this error message. Any ideas about how to fix it? I am using the R version 3.1.1, RNetLogo_1.0-1, the platform is x86_64-apple-darwin13.1.0 (64-bit), Java 7 update 60.

Sys.setenv(NOAWT=1)
library(JGR)
Sys.unsetenv("NOAWT")

JGR()
library(RNetLogo)

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
Kampai
  • 22,848
  • 21
  • 95
  • 95
sdaza
  • 1,032
  • 13
  • 29
  • 1
    Did you read Details section of `?NLStart` regarding use in OSX? I ask because it fairly clearly states this should not work outside the JGR environment. I also see not evidence that you followed the directions to execute `Sys.setenv(NOAWT=1)` – IRTFM Oct 28 '14 at 21:43
  • Even after using Sys.setenv(NOAWT=1), it doesn't work. – sdaza Oct 29 '14 at 07:43
  • Same problem here. https://groups.yahoo.com/neo/groups/netlogo-users/conversations/topics/16067 suggests that updating to Java 7 should have made the grade but it does not work on my side either (Maverick, RNetLogo_1.0-1, Java 8) – Martin Van der Linden Oct 30 '14 at 18:33
  • 1
    You installed Java 8, but are you sure that are actually successfully using it? It should not be possible for Java 8 to give a “Unsupported major.minor version 51.0” error. – Seth Tisue Nov 01 '14 at 01:21

5 Answers5

3

You need at least Java 7.

I have missed to update the requirements in the package description to Java >= 7. Sorry for that. The CRAN maintainers ask me to clean up the package, i.e. update to Java 7 and remove support for old Java and NetLogo versions.

If older Java should be used, get old RNetLogo version (e.g. 1.0-0) from CRAN archive.

Best wishes, Jan

Jan C. Thiele
  • 239
  • 1
  • 2
2

What version of RNetLogo are you using? According to http://cran.r-project.org/web/packages/RNetLogo/news.html , RNetLogo version 0.9-6 fixed a bug that caused the "Unsupported major.minor version 51.0" version error.

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
2

please check which Java version is used by R. I checked it on one of my Ubuntu installation with Java 7 without any problem. Yes, support for very old Java and NetLogo versions have been removed with 1.0-1 as requested by CRAN maintainers (that's not a bug).

Please execute the following functions in R to check which Java is active:

    library(rJava)
    .jinit()
    .jcall("java/lang/System", "S", "getProperty", "java.vm.version")
    .jcall("java/lang/System", "S", "getProperty", "java.vm.name")
    .jcall("java/lang/System", "S", "getProperty", "java.vm.info")
    .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
    .jcall("java/lang/System", "S", "getProperty", "sun.arch.data.model")

Cheers, Jan

Jan C. Thiele
  • 239
  • 1
  • 2
  • How did you set up rJava after its installation? I am still stuck here: https://github.com/s-u/rJava/issues/37 – sdaza Dec 06 '14 at 15:49
2

Wanted to put this as a comment, but I lost my right to commenting by awarding a bounty to the question and getting below 50 rep... :-S

@Jan : I executed the functions you mentioned and got the following

[1] 0
     .jcall("java/lang/System", "S", "getProperty", "java.vm.version")
[1] "20.65-b04-462"
     .jcall("java/lang/System", "S", "getProperty", "java.vm.name")
[1] "Java HotSpot(TM) 64-Bit Server VM"
     .jcall("java/lang/System", "S", "getProperty", "java.vm.info")
[1] "mixed mode"
     .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.6.0_65-b14-462-11M4609"
     .jcall("java/lang/System", "S", "getProperty", "sun.arch.data.model")
[1] "64"

I understand that R might not be picking up the right Java version. I also get the error message

Error in .jnew("nlcon/Preprocess") : 
  java.lang.UnsupportedClassVersionError: nlcon/Preprocess : Unsupported major.minor version 51.0 

Am I understanding correctly that version 51.0 corresponds to some update of Java 7? Should there be a problem with Java 7? Do we really need to make sure R finds and uses Java 8? I guess that R is still trying to use Java 7 suggest there is something wrong? Any idea how to fix this?

Edit following last answer by Jan

@Jan : thanks for following up on the question. I might chose to go back to older versions of RNetLogo if it solves the problem. The thing is I installed Java 8, so I would expect R to use it, but somehow it seems that it does not. For clarity, I'll start another question in order to figure out how to solve this ( see Getting R to use newer versions of java).

This being said from Getting R to use newer versions of java and the fact that the error message in R mentions version 51 I understand that I am indeed using Java 7, so there should be no problem with RNetLogo right?

Community
  • 1
  • 1
  • 2
    Could someone fix this? Any ideas? – sdaza Nov 08 '14 at 02:12
  • 1
    Not sure if it works on Mac but have you tried R CMD javareconf (see also here: http://r.789695.n4.nabble.com/Can-t-get-R-to-recognize-Java-for-rJava-installation-td4553023.html) – Jan C. Thiele Nov 08 '14 at 20:36
  • Thanks for the suggestion. I'll look into this when I get back to my mac next week. – Martin Van der Linden Nov 08 '14 at 21:07
  • I have got the same problem, and R CMD javareconf didn't change anything. I still get R pointing to Java Runtime Version 1.6.0, even though system("java -version") yields "java version 1.7.0." – Kenji Nov 14 '14 at 16:14
  • 1
    Thanks for all the suggestions. I have tried different ways to do it, but I am still not able change the java version R is using (1.6.0) :( – sdaza Dec 02 '14 at 17:42
  • 1
    The problem has to do with rJava. Here some details: https://github.com/s-u/rJava/issues/37 – sdaza Dec 06 '14 at 15:46
  • It seems for now the best solution is to use Windows: I haven't had any problems with Java 8 using Windows. – sdaza Dec 18 '14 at 16:31
2

After several weeks trying to fix it, RNetLogo is finally working on my laptop with Yosemite and The Capitan. Here you have technical details regarding the solution: https://github.com/s-u/rJava/issues/37

This is what I did (remember that I use R in terminal):

  1. Install Java 8 (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
  2. Install Java 6 from Mac (http://support.apple.com/kb/DL1572)
  3. It is necessary to define correctly the java home directory. I used /Library/Java/Home, but it could be another. You can use eclipse IDE (preferences, installed jREs) to define the directory.
  4. Reconfigure R using sudo R CMD javareconf -n in terminal
  5. In terminal, set the path to lijvm.dylib

jvm = 'ls /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre/lib/server/lijvm.dylib' sudo install_name_tool -id "$jvm" "$jvm"

  1. Install rJava as source install.packages("rJava", type="source")
  2. You can check in the terminal to make sure you have linked rJava against 1.8 and not 1.6.

DYLD_PRINT_LIBRARIES=1 R library(rJava) .jinit() .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")

Then, install RNetLogo. That's it.

sdaza
  • 1,032
  • 13
  • 29
  • I followed the method laid out by sdaza. Everything works hunky dory when using R and JGR through the terminal. However when I try the same using the R console or RStudio, not only does RNetLogo not work, rJava is no longer found. Anybody else have the same experience? – invictus Jun 18 '15 at 20:38
  • That worked perfectly on Linux as well. The key steps: (1) make sure that `/usr/lib/jvm/default-java` links to the correct Java, then (2) `sudo R CMD javareconf` as root; (3) reinstall `rJava` and then re-start R; (4) reinstall `RNetLogo`. – akhmed Aug 20 '15 at 19:11