I tried to install leiningen ( 2.X.X ) and I noticed that it throws an error at execution (e.g lein version). I use java 7 on Ubuntu 20.04. Could you please provide me with some feedback on how to resolve this?
The error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: clojure/main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:1070)
at java.lang.ClassLoader.loadClass(ClassLoader.java:414)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
I tried different version of Leiningen (always 2.X.X, I didn’t try 1.X.X versions) also downgrading Ubuntu. Unfortunately I can’t change the java version because it is a project requirement.
2
Answers
Clojure requires at least Java 8:
Java 7 is over a decade old. To use a modern language you need tools that aren’t ancient. If your project requirement is to use both Clojure and Java 7, then transitively it’s a requirement that your project will fail.
Clojure since version
1.10
has Java8 as minimum.
Leiningen since 2.9
uses Clojure 1.10. So any version up to 2.8.3 should work just fine
with Java7.
And indeed it works fine for me using e.g. 2.7.1 (which I picked,
because it is the only <2.9 version still in SDKMAN):
(with Leiningen 2.10 the
-version
call fails with the same error as inthe question)
This of course also means, that you have to stick to plugins and deps
from before 2018 too.
All that said: Update! At some point even Azul will end the support…