20

I am trying to run selenium-standalone-server 2.47.1.jar through command prompt.

But I am facing this error.

C:\automation\node_modules\selenium-webdriver>java -jar selenium-server-standalo
ne-2.47.1.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/gr
id/selenium/GridLauncher : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: org.openqa.grid.selenium.GridLauncher. Program wi
ll exit.

C:\automation\node_modules\selenium-webdriver>

Why am I getting this error?

I have JDK installed already(since I need to run netbeans).

Is there anything I am missing?

7
  • 1
    It seems the error is about conflicting your JDK versions. Aug 29, 2015 at 4:49
  • What JDK version do I need? The one I installed has this name jdk-6u10-windows-i586-p.exe. Its JDK 6 I think Aug 29, 2015 at 4:53
  • 1
    And what is your selenium running/compiled version ? Aug 29, 2015 at 4:55
  • 1
    Smruti, did you compile your project using 1.7 ? Aug 29, 2015 at 4:56
  • You mean, the selenium-standalone-server version? Its 2.47.1. selenium-server-standalo ne-2.47.1.jar @sᴜʀᴇsʜᴀᴛᴛᴀ Aug 29, 2015 at 4:57

3 Answers 3

33

java.lang.UnsupportedClassVersionError happens because the code was compiled with a higher version of Java than the one you're running it.

Version 51.0 of a class file corresponds to java 7

J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45

You need to upgrade your JDK from Java 6 to Java 7 or higher.

2
  • 7
    Worth noting that Java 8 also seems not to work with this file. Nov 11, 2015 at 17:06
  • Yup, not working for me either! I had upgraded, but still having the same issue...
    – Bruno Soko
    Dec 7, 2015 at 20:22
6

Just download the last JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

It helps me resolve the problem on my mac the problem was Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncher : Unsupported major.minor version 51.0

resolved by download and install Mac OS X x64 196.89 MB jdk-7u79-macosx-x64.dmg

2

A colleague of mine tried to use selenium-java-2.48.2.jar where he got the same error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncher : Unsupported major.minor version 51.0 ```

I sent him an old version selenium-java-2.44.0.jar and now it works in his environment just fine.

1
  • In package.json you can add: "selenium-webdriver": "2.44.x"
    – chovy
    Mar 18, 2016 at 21:13

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.