I wanted to install protractor in order to work with our AngularJS project.
Everything went OK till I ran the command:
webdriver-manager start
...and I got some errors:
seleniumProcess.pid: 5421
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncher : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
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)
Selenium Standalone has exited with code 1
Then I understood that I was using the wrong version of java (1.6.0_65).
So Ive got the latest one (1.8)
and basically the problem was that on terminal it would show me the old version. but on my actual computer would show me the latest.
However I tried uninstalling java by running this command:
sudo rm /usr/bin/java
and been getting this, no matter what I do.
sudo rm: /usr/bin/java: Operation not permitted
Has anyone experienced the same thing?
(Using OS X 'El Capitan' as my operating system)
You are using a mac and the default version of Java on mac osx is still Java 6 (Apple stopped producing their own version of Java a number of years ago). So, you need to manually install a more recent version of Java from Oracle to get the latest version.
Download the latest version of Java here. Then, run the downloaded dmg file and follow the instructions to complete the installation.
After installing Java 8, simply re-run webdriver-manager start and you should be good to go.
Related
Following the solutions online for Major Minor version of Java being incorrect on El Capitan, I saw several solutions which made you either disable rootless, which i didn't like the sound of, or just didn't work anymore in OS X El Capitan.
When trying to run webdriver-manager start on El Capitan, you may get an error saying:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/openqa/grid/selenium/GridLauncher : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
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)
Selenium Standalone has exited with code 1
The recommended fix for this online is to change the symlink that Mac OS X has to Java, which you can find by running echo $JAVA_HOME in the terminal.
This is pointing to the incorrect folder, and the error is because the application was compiled with a higher version of JRE than the machine is running in the terminal.
You should go to Oracle, and download the latest JRE version (http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
After this has been installed, you will have Java 8 on your machine, but it will not update the terminal properly. If you run java -version in your terminal, you'll see Java Version "1.6", you want this to say Java Version "1.8". The previous way to do this was to change the symlink manually, however, since El Capitan, Apple have made certain folders unchangable even to admin users, with their Rootless install. This includes the /usr folder.
There are two ways to fix this, the first is dangerous, and what everyone else seems to recommend. The second, is safer, and what I am putting here.
If you go to your System Preferences -> Java -> Java -> View... -> System and copy the Path field.
It will look something similar to the following:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
We want most of this path, except the /bin/java on the end.
So your path should now be copied as:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Run the following command in the terminal, replacing [PATH] with the path you have from above.
export JAVA_HOME="[PATH]"
and run that in the terminal.
Afterwards, run java -version again, and it should now say Java Version "1.8"
Now, webdriver-manager start should succeed.
Adding the following line to ~/.bash_profile worked for me:
export JAVA_HOME="$(/usr/libexec/java_home --version 1.8)"
You might have to restart your shell for these changes to reflect or just run:
. ~/.bash_profile
I'm trying to install Amazon Mechanical Turk command line tools on Ubuntu 14.04 LTS, using this tutorial. It requires Java, so I installed OpenJDK7. However, when attempting to run the command , I get the following error, which the internet informs me indicates the wrong Java version.
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at com.amazonaws.mturk.service.axis.AWSService.<clinit>(AWSService.java:104)
at com.amazonaws.mturk.cmd.AbstractCmd.initService(AbstractCmd.java:119)
at com.amazonaws.mturk.cmd.AbstractCmd.run(AbstractCmd.java:143)
at com.amazonaws.mturk.cmd.GetBalance.main(GetBalance.java:28)
Some of the documentation for the AMT tools indicates that I need JRE 1.5 (while others say "most recent version"), so I have been trying to install that. Since it's no longer available through apt-get, I downloaded the bin file and installed it at '/home/USERNAME/', (I don't use the machine much and didn't want to deal with sticking it at the end of a long chain of folders, so all my AWS stuff is in there) then put in my AWS keys and set the environment variables:
export JAVA_HOME="/home/USERNAME/jre1.5.0_22"
export MTURK_CMD_HOME="/home/USERNAME/aws-mturk-clt-1.3.1"
Then, checking my balance to make sure everything is configured, as specified in the AWS Getting Started PDF, I still get the same error shown above.
Did I do something wrong when installing JRE 1.5? Is it still using OpenJDK7, or is JRE 1.5 also no good? I'm really at my wit's end here.
It turns out that I am an idiot and installed Java wrong.
Instructions for anyone else having this problem: http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html
I'm fully aware that this question has already been asked in a way in this thread:
Cassandra:UnsupportedClassVersionError
However, the answer/s given there, which I accept, don't solve my problem as I do have a current version of Java as detailed below:
D:\Development\Cassandra\apache-cassandra-2.0.6>java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)
Knowing this, I still receive the error when starting Cassandra:
D:\Development\Cassandra\apache-cassandra-2.0.6>bin\cassandra -f
Starting Cassandra Server
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/cassandra/service/CassandraDaemon : 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)
Could not find the main class: org.apache.cassandra.service.CassandraDaemon. Program will exit.
I'm running on a Windows XP machine using the command prompt (not Cygwin) to start Cassandra and I'm able to start older versions of Cassandra without any issue (apache-cassandra-1.1.4). Am I doing something incorrect with the later version of Cassandra or have I missed something somewhere in my configuration that is blindingly obvious?
The only plausible explanation for that exception is that a Java 6 (or earlier) JVM is being use to run code that was compiled for the Java 7 target platform.
This contradicts what you believe to be happening. Nevertheless, it is the only plausible explanation.
I suggest that you make a copy of the cassandra wrapper script (in the same directory), and hack it to:
add set -x at the start to see what commands are actually being run by the script.
add echo $PATH, echo $JAVA_HOME and so on to see what the key environment variables are in the script's environment.
add a line to run java -version using the exact same command path that is being use to run the JVM for real.
This should reveal which of your beliefs / assumptions about what is happening are incorrect.
I did try with uninstalling java 1.7 and installing the latest java 8 got solved my issue.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Exception in thread “main” java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0)
My Java program which I run on Mac & Windows is not working. Instead I get this error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: menus/Main_Screen : 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)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Does anyone know how to fix this? Thanks.
Class version 51.0 is generated by Java 7.
You're trying to run with an earlier version, probably Java 6.
You need to call the Java 7 version of the java command.
The version used to run NetBeans is set in NetBeans/etc/netbeans.conf.
The version used to build and run a project is set by the project properties.
You can tell NetBeans about a new Java version through the Tools > Java Platforms
Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(
It seems your java runtime version is different (lower) version from compile time version.
The general rule is this.
If take a *.class compiled by a version of Java EARLIER than the JRE, it should work in that JRE.
Because the later JRE is supposed to "know" previous versions of format.
If take a *.class compiled by a version of Java LATER than the JRE, it should not work in that JRE.
Because the earlier JRE is not supposed to know the future versions of format.
In your case the code is simply compiled by the version of Java issued after the version of the JRE.
I have been coding with Eclipse and testing the code using Terminal on OS X 10.7.4. When I ran the code with Eclipse, it worked. However, running with terminal gave me the following error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: PacketPrinter : 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)
I checked my java and javac version. They are both 1.7. I have been googling but could not find anything.
You're probably not using the same runtime on the command line as when you launch the program from within Eclipse.
Try executing
java -version
from the command line to see which version of java you're using on the terminal.
(You can also run which java to see exactly which file is being executed.)
It seems you have a different version of java running in eclipse and in your terminal.
Do the following:
In the terminal type: java -version
In eclipse goto the preferences and look in Java/Installed JREs
Compare the versions.
Point you $JAVA_HOME and $PATH variables to the same JRE you use in Eclipse.
As aioobe said check you java version using following command
java -version
Copy the contents of the PATH settings to a notepad and check if you have any other java version path present in it and if it is before that of the 7. If so, remove that path in the PATH setting and save it.
I would suggest you to re logging after doing it.
AFAIK this error comes when you have older version java path present in path.