java.lang.UnsupportedClassVersionError: com/CucumberOptions/RunCukeTest : Unsupported major.minor ve
- 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
IDE : Eclipse
Programming Language : Java7
Unit testing framework : Junit
Framework used : BDD
Tools used to make this framework : Cucumber
Build tool : Maven
You can run the code from eclipse like this
‘Maven Clean Install’
Or
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:
Download java 7 at your local Operating system.
You can use this link : http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Set PATH , JAVA_HOME at your environment variables according to the OS you have.
You can use this link : http://www3.ntu.edu.sg/home/ehchua/programming/howto/jdk_howto.html
Once this is done , now its time to make changes in eclipse, for this you need to do the below steps:
Go to Eclipse — > Windows –> Preferences –> Java –> InstalledJRE.
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:
Go to Eclipse — > Windows –> Preferences –> type compiler
Now Java –> compiler –>Change the compiler to 1.7 from 1.6(or whichever is set).

Step 2
Go to your project and right-click over it.
Now go to ‘Java BuildPath’ and select ‘JRE System Library’

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

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 🙂
Comments