java.lang.UnsupportedClassVersionError: org/openqa

2020-07-05 06:38发布

问题:

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)

回答1:

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)



回答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.



回答3:

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.



回答4:

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.



回答5:

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.



回答6:

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!