running mvn giving Unsupported major.minor version 51.0 on Mac Os

HI,
I just tried running mvn it give the following error :
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : 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 org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:254)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:144)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Open in new window


Dont know why this is happening ?
Some details about java and maven :
DDVMACROBINSU:flock-snippets robinsuri$ [b]which mvn[/b]
/Users/robinsuri/Downloads/apache-maven-3.3.3/bin/mvn
DDVMACROBINSU:flock-snippets robinsuri$ [b]which java[/b]
/usr/bin/java
DDVMACROBINSU:flock-snippets robinsuri$ [b]ls -l `which java`[/b]
lrwxr-xr-x  1 root  wheel  74 Oct 29  2014 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
DDVMACROBINSU:flock-snippets robinsuri$ [b]java -version[/b]
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Open in new window

Rohit BajajAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dpearsonCommented:
UnsupportedClassVersionError is Java's rather unfriendly way of saying, you compiled this code on a newer version of Java than you are trying to run it on.

E.g.  mvn was maybe built using Java 8 and you are now running in on Java 7?

Best solution is usually to upgrade your Java runtime to the latest version.
0
Rohit BajajAuthor Commented:
my java version as mentioned in the above is 1.7
i think that mean its java 7.
so should i remove it and install java 8 ?
on maven website it mentions that maven 3.3 is compatible with java 7.
thats confusing...
also i dont have the environment variable JAVA_HOME set on my mac.dont know if thats a problem
0
dpearsonCommented:
so should i remove it and install java 8 ?

Yes I think that's what you should do.  Java 8 is the latest anyway, so this is a good step and I think it'll resolve your problems here.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rohit BajajAuthor Commented:
wow upgrading resolved the issue :) thanks a lot
0
dpearsonCommented:
Excellent.

It's really just a very confusing error message from Java - if it said upgrade, it wouldn't be so bad :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.