illegalargumentexception: 'unsupported class file major version 57'

Background: MacBook, running spark locally, encountered this error

user_log.where(user_log.userId== '1002').collect()

return:

illegalargumentexception: ‘unsupported class file major version 57’

The reason for the error: the JDK version is wrong, the JDK installed before is the latest version of JDK13 (jdk-13.0.2)

Solution: uninstall JDK13, download and install the old version JDK8 (jdk-8u241)

Specific steps:

1. Check the existing JDK version, open the terminal, and enter:

$ java -version

For example, my return:

java version "13.0.2" 2020-01-14

2. Uninstall JDK: switch to the directory: /Library/Java/JavaVirtualMachines — delete JDK13

$ cd /Library/Java/JavaVirtualMachines
$ sudo rm -rf jdk-13.0.2.jdk

3. Install JDK (jdk-8u241), download jdk-8u241-macosx-x64.dmg:

Download "jdk-8u241" to the local, double-click to install, then check the JDK version, the display is as follows:

java version "1.8.0_241"

4. Go back to the jupyter notebook again and run the spark command:

user_log.where(user_log.userId== '').collect()

Back to normal:

[Row(artist=None, auth=‘Logged Out’, firstName=None, gender=None, itemInSession=0, lastName=None, length=None, level=‘free’, location=None, method=‘PUT’, page=‘Login’, registration=None, sessionId=5598, song=None, status=307, ts=1513721196284, userAgent=None, userId=’’),
Row(artist=None, auth=‘Logged Out’, firstName=None, gender=None, itemInSession=26, lastName=None, length=None, level=‘paid’, location=None, method=‘GET’, page=‘Home’, registration=None, sessionId=428, song=None, status=200, ts=1513721274284, userAgent=None, userId=’’)…

Note: It is said that other old versions of JDK are also available, such as JDK11

If your problem is solved, please manually like it~

Guess you like

Origin blog.csdn.net/weixin_45281949/article/details/104247038