Search code examples
javaunsupported-class-version

java.lang.UnsupportedClassVersionError: com/crawljax/cli/JarRunner : Unsupported major.minor version 51.0


I have downloaded the program:

wget https://github.com/crawljax/crawljax/releases/download/crawljax-3.6/crawljax-cli-3.6.zip

Unzip it:

unzip crawljax-cli-3.6.zip

get in the folder and run:

java -jar crawljax-cli-3.6.jar

This is the error I get:

java -jar crawljax-cli-3.6.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/crawljax/cli/JarRunner : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: com.crawljax.cli.JarRunner. Program will exit.

I have done this:

apt-get install default-jre
apt-get install default-jdk

But is the same error

My version of java:

javac -version

javac 1.6.0_35

java -version

java version "1.6.0_35" OpenJDK Runtime Environment (IcedTea6 1.13.7) (6b35-1.13.7-1~deb7u1) OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)

I have read this is because I have compiled with a higher version than the one is executing on the JVM, but I have no source code here to recompile, I just have the .jar.


Solution

  • As you noted, you are attempting to run a JAR compiled for Java 7 with JRE 6. Just install JRE from Java 7:

    apt-get install openjdk-7-jre 
    apt-get install openjdk-7-jdk # just for good measures
    

    And set it as the default JRE:

    update-alternatives --config java # and select Java 7