12

I got this selenium server jar file in my Selenium folder. When I'm trying to execute this with java - jar selenium-server-standalone-2.0b3.jar command I'm getting this version difference error. Can anyone please show me where I'm making a mistake?

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/gr
id/selenium/GridLauncher (Unsupported major.minor version 50.0)
        at java.lang.ClassLoader.defineClass0(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$100(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)
Valentin Lorentz
  • 9,556
  • 6
  • 47
  • 69
sam1132
  • 181
  • 1
  • 2
  • 9
  • 2
    You are likely using a a version of java older than the version the software was compiled in. – Brian Jul 18 '12 at 00:17

7 Answers7

17

That message (with version 50.0) indicates that Selenium server requires java 6 to run, but you're trying to run it with some earlier version of java.

To find out what version of java you're using, run:

java -version

If you have java 6 installed, but it isn't getting used, you may have to give the full path name to the java executable, so something like this if on linux:

/usr/local/jre6/bin/java -jar selenium.jar

or like this if on windows:

"C:\Program Files (x86)\Java\jre6\bin\java.exe" -jar selenium.jar

(Of course, you'll need to adjust that command to match where java actually lives on your machine)

Daniel Martin
  • 23,083
  • 6
  • 50
  • 70
  • I am actually using the version 6, When when i restarted everything i worked f9. – sam1132 Jul 18 '12 at 23:18
  • version update e.g. on centos 7 3.10.0-693.21.1.el7.x86_64 with `java -jar selenium-server-standalone-3.14.0.jar` got error "Unsupported major.minor version 52.0". Solution: `yum install java-1.8.0-openjdk-devel` – gaoithe Nov 01 '18 at 12:39
2

I had the same problem, I was using jre6, I went to the project properties, changed the JRE system library to use jre1.8 and it worked.. you can select alternate jre and add the latest jre installed on your system.

Himayath
  • 21
  • 1
1

Besides the Java version, the Java vendor can apparently be another important variable. I landed on this thread with a variation of the OP's problem where the stack trace indicated that Java 8 was required, even though I was already using OpenJDK 8.

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncherV3 : Unsupported major.minor version 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

Switching to Oracle's JVM got me past this.

Renats Stozkovs
  • 2,549
  • 10
  • 22
  • 26
1

In my case when I did 'java -version' I got this:

Picked up _JAVA_OPTIONS: -Duser.home=C:\Users\xxxx
java version "1.7.0_151"
Java(TM) SE Runtime Environment (build 1.7.0_151-b33)
Java HotSpot(TM) Client VM (build 24.151-b33, mixed mode)

and my 'JAVA_HOME' was different as mentioned below:

C:\Program Files\Java\jdk1.8.0_91

So I have just added 'jdk1.8.0_91' in the path under my Environment Variables like this:

BEFORE:

C:\Program Files (x86)\Java\jre7\bin;

AFTER:

C:\Program Files\Java\jdk1.8.0_91\jre\bin; C:\Program Files (x86)\Java\jre7\bin;

And after that I was able to run 'webdriver-manager' successfully. I hope this will helpful for others.

tutorialfeed
  • 965
  • 3
  • 11
  • 24
0

right click on your project folder -> build path -> configure build path -> check if your selenium version matches jre ( for selenium 52 jre 8 version is required) if it not matches then click on jre -> edit -> alternate jre -> add -> give desired path -> ok -> finish

this works for me.

Mrunal
  • 1
-1

I faced similar problem. Just install Nodejs, Protractor and JDK with latest versions. It works without any issues.

Initially I faced issue with JRE version mismatch.

I have Selenium web driver 3.0 and Jre 1.7. I uninstalled all and installed with latest versions.

Moses Davidowitz
  • 982
  • 11
  • 28
-1

Install the latest version of java i.e. 12 using

brew cask install java

Uninstall the one downloaded from Oracle following https://www.java.com/en/download/help/mac_uninstall_java.xml

Might help a great deal!

ascripter
  • 5,665
  • 12
  • 45
  • 68
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/22571468) – deHaar Mar 26 '19 at 10:30
  • @deHaar: Actually the answer contains more than just a link, at least a suggestion how the problem can be solved – ascripter Mar 26 '19 at 11:09