问题
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
回答1:
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
回答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.
回答3:
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
回答4:
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?
回答5:
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):
- Install Java 8 (http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
- Install Java 6 from Mac (http://support.apple.com/kb/DL1572)
- 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. - Reconfigure R using
sudo R CMD javareconf -n
in terminal - 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"
- Install rJava as source
install.packages("rJava", type="source"
) - 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.
来源:https://stackoverflow.com/questions/26618105/rnetlogo-not-working-on-mac-yosemite