I have Python 2.6 (32-bit) and java 1.7 on my Mac. I use make command to compile pylucene 2.9.4 on my Mac 10.8.5. An error occurs: Unsupported major.minor version 51.0. Like:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/pylucene/analysis/PythonTokenizer : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
While loading org/apache/pylucene/analysis/PythonTokenizer
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/runpy.py", line 122, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/runpy.py", line 34, in _run_code
exec code in run_globals
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/jcc/__main__.py", line 98, in <module>
cpp.jcc(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/jcc/cpp.py", line 496, in jcc
cls = findClass(className.replace('.', '/'))
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/jcc/cpp.py", line 73, in findClass
cls = _findClass(className)
jcc.cpp.JavaError
make: *** [compile] Error 255
I search this error. Most of answers say that is a mismatch problem. It is because some classes are compiled on a higher java version but I want to run it on a lower java version. I use python 2.6, and I check the java version, it is java 1.7. Like:
joekaojoekaoMac-mini:pylucene-2.9.4-1 joekaojoekao-mini$ java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
I also open PythonTokenizer.class that causes the error in binary format. It is compiled in java 1.7 because its number is x0000 0033. Its fist line looks like this:
cafe babe 0000 0033 001d 00a0 0500 1609
But in the makefile of pylucene, it recommends use java 1.6. So I am confused that why it asks me to use java 1.6 to compile pylucene but the class file (PythonTokenizer.class) used by it is compiled by java 1.7.
# Mac OS X 10.6 (64-bit Python 2.6, Java 1.6)
PREFIX_PYTHON=/System/Library/Frameworks/Python.framework/Versions/2.6
ANT=ant
PYTHON=$(PREFIX_PYTHON)/bin/python
JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64
NUM_FILES=2
So should I use java 1.6 or java 1.7? Or are there any other settings that I missed?