castorini / anserini

Anserini is a Lucene toolkit for reproducible information retrieval research
http://anserini.io/
Apache License 2.0
1.03k stars 458 forks source link

JVM exception "has been compiled by a more recent version of the Java Runtime" error when importing pyserini #1814

Closed parraro closed 2 years ago

parraro commented 2 years ago

I get an error regarding the anserini classes being compiled with a newer version of Java. I tried changing my system's java to be java 8 to match the java runtime 52 required but the error remains. Traceback (most recent call last): File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 848, in exec_module File "", line 219, in _call_with_frames_removed File "/home/esteban/Documents/FinBERT-QA-master/src/finbert_qa.py", line 13, in from pyserini.search import pysearch File "/project/venv/lib/python3.8/site-packages/pyserini/search/init.py", line 17, in from .lucene import JQuery, JDisjunctionMaxQueryGenerator, get_topics,\ File "/project/venv/lib/python3.8/site-packages/pyserini/search/lucene/init.py", line 17, in from ._base import JQuery, JDisjunctionMaxQueryGenerator, get_topics, \ File "/project/venv/lib/python3.8/site-packages/pyserini/search/lucene/_base.py", line 34, in JQrels = autoclass('io.anserini.eval.Qrels') File "project/venv/lib/python3.8/site-packages/jnius/reflect.py", line 211, in autoclass c = find_javaclass(clsname) File "jnius/jnius_export_func.pxi", line 26, in jnius.find_javaclass File "jnius/jnius_utils.pxi", line 91, in jnius.check_exception jnius.JavaException: JVM exception occurred: io/anserini/eval/Qrels has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 java.lang.UnsupportedClassVersionError python-BaseException

System details: linux mint 20 java -version output:
openjdk version "1.8.0_312" OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07) OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode) pyserini and pyjnius versions: pyjnius 1.4.1 pyserini 0.16.0

I am trying to run the code on Pycharm.

lintool commented 2 years ago

As stated in our README: https://github.com/castorini/anserini#getting-started

You'll need Java 11 and Maven 3.3+ to build Anserini.

parraro commented 2 years ago

Thank you.

Using the openjdk 11 resulted in the same error. I realized after your comment that I needed to install and use Oracle's jdk 11 for it to work.

Thank you for your help.