Automation, Automation Framework, BDD, Behaviour Driven Development, eclipse, Functional Testing, Java, Testing

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

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

  • ‘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).

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 🙂

 

Advertisements

2 thoughts on “java.lang.UnsupportedClassVersionError: com/CucumberOptions/RunCukeTest : Unsupported major.minor version 51.0”

  1. I see a lot of interesting articles here, i know
    writing articles requires a lot of time, but i know unlimited source
    of content for your website , just search in google – rewriter creates an unique article in a minute

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s