skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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):

    % java -version
    openjdk version "1.7.0_352"
    OpenJDK Runtime Environment (Zulu 7.56.0.11-CA-linux64) (build 1.7.0_352-b01)
    OpenJDK 64-Bit Server VM (Zulu 7.56.0.11-CA-linux64) (build 24.352-b01, mixed mode)
    % lein -version
    Leiningen 2.7.1 on Java 1.7.0_352 OpenJDK 64-Bit Server VM
    

    (with Leiningen 2.10 the -version call fails with the same error as in
    the 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…

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search