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.
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 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.
I have absolutely no idea what has gone wrong here. One day I have a perfectly working system using rosjava, and then the next morning I am getting this error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/ros/RosRun : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: org.ros.RosRun. Program will exit.
I haven't changed any code, updated any files, nothing. This just happened. Does anyone have any idea why?
Things I have tried: After doing research on errors similar to this, I found out that it occurs when java versions do not match. 51 is Java 1.7. So I checked out my own java version with:
java -version
and got:
java version "1.6.0_33"
OpenJDK Runtime Environment (IcedTea6 1.13.5) (6b33-1.13.5-1ubuntu0.12.04)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
So I am running java 1.6. Makes sense, the error is telling me RosRun is 1.7. Let me check.
$ file RosRun.class
RosRun.class: compiled Java class data, version 50.0 (Java 1.6)
Well thats not the case. That means my code must be compiling in 1.7. Let me check:
$ file project/build/classes/main/com/github/hsmrs_gui/project/GuiNode.class
project/build/classes/main/com/github/hsmrs_gui/project/GuiNode.class: compiled Java class data, version 50.0 (Java 1.6)
I'm at a loss. Can anyone help?
I ran $sudo apt-get upgrade which turned the output of $java -version into:
java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)
and then reran my code. It works now. I still have no idea why this broke in the first place though.
I'm running into this nasty bug:
2013-06-18 15:06:01.908 java[3805:2617] Cocoa AWT: Apple AWT Java VM was loaded on first thread -- can't start AWT. (
0 liblwawt.dylib 0x000000016cf11ba2 JNI_OnLoad + 468
1 libjava.dylib 0x0000000109fbd6d1 Java_java_lang_ClassLoader_00024NativeLibrary_load + 207
2 ??? 0x000000010a093f90 0x0 + 4463345552
)
_NSJVMLoadLibrary: NSAddLibrary failed for /libjawt.dylib
JavaVM FATAL: lookup of function JAWT_GetAWT failed. Exit
My current intelliJ SDK is set to 1.6 for compatibility and i'm using Mountain Lion 10.8.4.
The interesting this is that it runs fine on intelliJ, but give me the above error when running: java -jar jarfile.jar
The above code runs and opens the GUI application for a split second before closing and giving me the error. Thanks for helping out!
edit: the permission denied portion of the error has been removed as it was not a contributor to the specific error:
java -jar /Users/santoki/Documents/workspace/copakb\ client_b/copakb-client/out/artifacts/copakb_client_jar/copakb-client.jar
Edit 2:
I switched the target to 1.6 by doing, and get the following error:
Mac-mini:~ bigbitecode$ export JAVA_HOME=`/usr/libexec/java_home -v '1.6*'`
Mac-mini:~ bigbitecode$ java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06-451-11M4406)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01-451, mixed mode)
Mac-mini:~ bigbitecode$ java -jar /Users/bigbitecode/Documents/workspace/sys\ sys_b/sys-client/out/artifacts/sys_client_jar/sys-client.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: SysClient/data/gui/SysClient : 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)
If you see a permission denied error you should try using sudo to run your command...
sudo java -jar jarfile.jar
You should also check any files that your jar accesses and make sure that you have set the correct permissions for the required operation. You can use chmod for this
sudo chmod a+rx <you_filename_here>
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.