top of page

java.lang.UnsupportedClassVersionError: com/CucumberOptions/RunCukeTest : Unsupported major.minor ve

  • Writer: khyati sehgal
    khyati sehgal
  • Aug 14, 2014
  • 2 min read

Hi all, I am trying to run an existing project of cucumber in my existing eclipse and faced an issue. In this piece of write-up, I will be sharing the resolution of the Error I got while executing the project.

Tools and specifications

  1. IDE : Eclipse

  2. Programming Language : Java7

  3. Unit testing framework : Junit

  4. Framework used : BDD

  5. Tools used to make this framework : Cucumber

  6. Build tool : Maven

You can run the code from eclipse like this

  1. ‘Maven Clean Install’

Or

  1. Right-click on your java file and select Run as Junit Test. Using any of these commands you can run your project.

I tried the second option and I got the below error.

java.lang.UnsupportedClassVersionError: com/CucumberOptions/RunCukeTest : 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)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
 

Resolution

Step 1

This is an java version issue. I had java 6 at my local and the code has java 7 dependencies in it. So you have to make changes in eclipse IDE and your OS. Follow these steps:

  1. Download java 7 at your local Operating system.

  1. Set PATH , JAVA_HOME at your environment variables according to the OS you have.

Once this is done , now its time to make changes in eclipse, for this you need to do the below steps:

  1. Go to Eclipse — > Windows –> Preferences –> Java –> InstalledJRE.

  2. Now here Go to Search ,and give the path of the JDK 7 you have installed

This will set the java version of eclipse IDE to Java7.

OR

1. Right click on your project –> Properties –> Java Build Path –>Add Library –> JRE System Library –> Search –> and give the path of the JDK 7 you have installed .

Next you need to make the updates in your project also, for this you need to do these steps:

  1. Go to Eclipse — > Windows –> Preferences –> type compiler

  2. Now Java –> compiler –>Change the compiler to 1.7 from 1.6(or whichever is set).

Java7

Step 2

Go to your project and right-click over it.

Now go to ‘Java BuildPath’ and select ‘JRE System Library’

JRE-7

And click on Edit JRE system, you will land to the below screen. Click on environment and select Java SE 1.7

JRE-7(jre)

Now click Finish and Ok.

Refresh the workspace in which you are working and you are done with the fixes.

That’s all you need to do, thanks for reading and happy testing 🙂

Recent Posts

See All

Comments


bottom of page