javaclojureleiningen

Leiningen 2 with java 7


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.


Solution

  • Clojure requires at least Java 8:

    Clojure depends on Java and all Clojure code is compiled to Java 8 compatible bytecode (newer versions of Java can load this as well).

    • Minimum runtime dependency: 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.