0

I'm fully aware that this question has already been asked in a way in this thread:

Cassandra:UnsupportedClassVersionError

However, the answer/s given there, which I accept, don't solve my problem as I do have a current version of Java as detailed below:

D:\Development\Cassandra\apache-cassandra-2.0.6>java -version

java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)

Knowing this, I still receive the error when starting Cassandra:

D:\Development\Cassandra\apache-cassandra-2.0.6>bin\cassandra -f Starting Cassandra Server Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/cassandra/service/CassandraDaemon : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: org.apache.cassandra.service.CassandraDaemon. Program will exit.

I'm running on a Windows XP machine using the command prompt (not Cygwin) to start Cassandra and I'm able to start older versions of Cassandra without any issue (apache-cassandra-1.1.4). Am I doing something incorrect with the later version of Cassandra or have I missed something somewhere in my configuration that is blindingly obvious?

Community
  • 1
  • 1
Azkuma
  • 301
  • 2
  • 8
  • How do you start cassandra? The stacktrace is definitively not produced by a Java 7 vm. – Dirk Lachowski Apr 09 '14 at 14:39
  • I start it using bin\cassandra -f as I do when starting the older version. – Azkuma Apr 09 '14 at 14:40
  • It is possible that JAVA_HOME environment variable points to JDK6 while the PATH points to JDK7. This would explain the proper java version from the command line and improper from the cassandra startup script. What is the output of `"%JAVA_HOME%\bin\java" -version` (on Windows)? – Oleg Estekhin Apr 09 '14 at 14:41
  • Or there is a `JAVA_HOME` entry in one of your `cassandra.in.sh`. – Dirk Lachowski Apr 09 '14 at 14:42
  • No, I have made absolutely sure that both my JAVA_HOME and PATH contain the correct settings e.g. JAVA_HOME = D:\Development\Java\jdk1.7.0_45\ and PATH = D:\Development\Java\jdk1.7.0_45\bin; – Azkuma Apr 09 '14 at 14:43
  • What's in your `cassandra.in.sh`? – Dirk Lachowski Apr 09 '14 at 14:44
  • In my cassandra.in.sh is the following: # JAVA_HOME can optionally be set here #JAVA_HOME=/usr/local/jdk6, which shows two entries there but both are commented out so cannot possibly affect the startup, right?? – Azkuma Apr 09 '14 at 14:48
  • Possible duplicate of [Cassandra:java.lang.UnsupportedClassVersionError](http://stackoverflow.com/questions/19333220/cassandrajava-lang-unsupportedclassversionerror) – Raedwald Jan 13 '16 at 11:05

2 Answers2

0

The only plausible explanation for that exception is that a Java 6 (or earlier) JVM is being use to run code that was compiled for the Java 7 target platform.

This contradicts what you believe to be happening. Nevertheless, it is the only plausible explanation.

I suggest that you make a copy of the cassandra wrapper script (in the same directory), and hack it to:

  1. add set -x at the start to see what commands are actually being run by the script.

  2. add echo $PATH, echo $JAVA_HOME and so on to see what the key environment variables are in the script's environment.

  3. add a line to run java -version using the exact same command path that is being use to run the JVM for real.

This should reveal which of your beliefs / assumptions about what is happening are incorrect.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
0

I did try with uninstalling java 1.7 and installing the latest java 8 got solved my issue.

Ajay Takur
  • 6,079
  • 5
  • 39
  • 55