Java Problem - major.minor version 51.0
Posted: Wed May 21, 2014 11:13 am
Hi,
I am relatively new to using the Raspberry Pi and Java so I apologise if the answer to my issue appears obvious to you all. I installed Java using:
sudo apt-get update && sudo apt-get install oracle-java7-jdk
When I check the version installed via terminal I get the following outputs:
pi@raspberrypi ~ $ java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1~deb7u1+rpi1) OpenJDK Zero VM (build 20.0-b12, mixed mode)
pi@raspberrypi ~ $ javac -version
javac 1.7.0_40
I wrote a simple java file called HelloWorld and compiled the file. However when I try to execute the script I get the following error message:
pi@raspberrypi ~ $ java HelloWorld
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
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:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: HelloWorld. Program will exit.
I've Googled the error and found various suggestions to resolve the issue; however some of these solutions are for different operating systems, devices and versions of Java. I don’t want to damage anything and feel like I’m guessing.
I’d appreciate it if someone could offer a solution or direct me to a post I’ve missed that can walk me through what I need to do.
My operating system is Rasbian Weezy.
Thanks in advance
I am relatively new to using the Raspberry Pi and Java so I apologise if the answer to my issue appears obvious to you all. I installed Java using:
sudo apt-get update && sudo apt-get install oracle-java7-jdk
When I check the version installed via terminal I get the following outputs:
pi@raspberrypi ~ $ java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1~deb7u1+rpi1) OpenJDK Zero VM (build 20.0-b12, mixed mode)
pi@raspberrypi ~ $ javac -version
javac 1.7.0_40
I wrote a simple java file called HelloWorld and compiled the file. However when I try to execute the script I get the following error message:
pi@raspberrypi ~ $ java HelloWorld
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
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:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: HelloWorld. Program will exit.
I've Googled the error and found various suggestions to resolve the issue; however some of these solutions are for different operating systems, devices and versions of Java. I don’t want to damage anything and feel like I’m guessing.
I’d appreciate it if someone could offer a solution or direct me to a post I’ve missed that can walk me through what I need to do.
My operating system is Rasbian Weezy.
Thanks in advance