RWeka throws java.lang.UnsupportedClassVersionErro

2019-02-20 21:03发布

问题:

I'm getting the following error message with RWeka 0.4-28 under OS 10.5.5 when I try to create classifiers:

Error in .jnew("weka/core/Attribute", attname[i], .jcast(levels, "java/util/List")) : java.lang.UnsupportedClassVersionError: weka/core/Attribute : Unsupported major.minor version 51.0

I've checked in terminal and my Java is up-to-date

java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)

Is this a bug in RWeka or something with my configuration?

回答1:

Are you sure that you're running RWeka using JDK 8? Based on the UnsupportedClassVersionError, it appears you're running the application using JDK 6. major.minor version 51.0 indicates that the classes for RWeka were compiled with JDK 7, which should be handled fine by JDK 8 (but not by JDK 6).

Can you provide the output of the following command in your terminal? Also, can you provide more details about how you're launching the app, e.g. using a shell script, Launchpad icon in the Dock, etc.

$ java -version

Update: have you tried updating R to use JDK 8?

$ sudo R CMD javareconf


回答2:

You might have to replace the /usr/bin/java symlink so that it points to /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java instead:

sudo rm /usr/bin/java
sudo ln -s /Library/Internet\ PlugIns/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin


标签: java r rweka