-
Notifications
You must be signed in to change notification settings - Fork 7
Selenium Java error on Linux
Trying to set up RSelenium
, after running rsDriver()
and allowing it to install [3 versions of] Selenium,
find / -iname "selenium-server-standalone-*" 2> /dev/null
/home/louis/.local/share/binman_seleniumserver/generic/3.3.1/selenium-server-standalone-3.3.1.jar
/home/louis/.local/share/binman_seleniumserver/generic/3.4.0/selenium-server-standalone-3.4.0.jar
/home/louis/.local/share/binman_seleniumserver/generic/3.3.0/selenium-server-standalone-3.3.0.jar
rsDriver()
reports what appears to be an incompatibility with my default Java, reproduced directly via:
java -jar /home/louis/.local/share/binman_seleniumserver/generic/3.4.0/selenium-server-standalone-3.4.0.jar
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)
According to StackOverflow this "52.0" corresponds to:
- J2SE 9 = 53
- 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
Thus, the 'major.minor version 52.0' error is possibly because the jar was compiled in jdk 1.8, but you are trying to run it using a jdk 1.7 environment. The reported number is the required number, not the number you are using. To solve this, it's always better to have the jdk and jre pointed to the same version.
Running find / -iname "jre*" 2> /dev/null
I can see that I have:
/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
/usr/lib/jvm/java-7-openjdk-amd64/jre
/usr/lib/jvm/java-6-openjdk-amd64/jre
/usr/share/jetty/jre1.5
/usr/share/jetty/lib/jre1.5
to choose from, while my default Java is:
ls -l `which java`
lrwxrwxrwx 1 root root 22 Apr 6 2014 /usr/bin/java -> /etc/alternatives/java
ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 46 Apr 6 2014 /etc/alternatives/java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
So in short I need to update my JRE to 8.0 to match the jar compiled in JDK 1.8